From 9d910320f382a3b96488bd27cd1c83daf161adf2 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 4 Sep 2020 14:18:01 +0200 Subject: [PATCH] archive/zzip: pass std::shared_ptr as template parameter This eliminates a tiny amount of overhead because the compiler can choose how to pass the parameter. --- src/archive/plugins/ZzipArchivePlugin.cxx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/archive/plugins/ZzipArchivePlugin.cxx b/src/archive/plugins/ZzipArchivePlugin.cxx index 00fcc6056..143cd33af 100644 --- a/src/archive/plugins/ZzipArchivePlugin.cxx +++ b/src/archive/plugins/ZzipArchivePlugin.cxx @@ -54,8 +54,9 @@ class ZzipArchiveFile final : public ArchiveFile { std::shared_ptr dir; public: - explicit ZzipArchiveFile(std::shared_ptr &&_dir) noexcept - :dir(std::move(_dir)) {} + template + explicit ZzipArchiveFile(D &&_dir) noexcept + :dir(std::forward(_dir)) {} virtual void Visit(ArchiveVisitor &visitor) override; @@ -91,11 +92,12 @@ class ZzipInputStream final : public InputStream { ZZIP_FILE *const file; public: - ZzipInputStream(const std::shared_ptr _dir, const char *_uri, + template + ZzipInputStream(D &&_dir, const char *_uri, Mutex &_mutex, ZZIP_FILE *_file) :InputStream(_uri, _mutex), - dir(_dir), file(_file) { + dir(std::forward(_dir)), file(_file) { //we are seekable (but its not recommendent to do so) seekable = true;