Commit 9d910320 authored by Max Kellermann's avatar Max Kellermann

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.
parent c53074ef
...@@ -54,8 +54,9 @@ class ZzipArchiveFile final : public ArchiveFile { ...@@ -54,8 +54,9 @@ class ZzipArchiveFile final : public ArchiveFile {
std::shared_ptr<ZzipDir> dir; std::shared_ptr<ZzipDir> dir;
public: public:
explicit ZzipArchiveFile(std::shared_ptr<ZzipDir> &&_dir) noexcept template<typename D>
:dir(std::move(_dir)) {} explicit ZzipArchiveFile(D &&_dir) noexcept
:dir(std::forward<D>(_dir)) {}
virtual void Visit(ArchiveVisitor &visitor) override; virtual void Visit(ArchiveVisitor &visitor) override;
...@@ -91,11 +92,12 @@ class ZzipInputStream final : public InputStream { ...@@ -91,11 +92,12 @@ class ZzipInputStream final : public InputStream {
ZZIP_FILE *const file; ZZIP_FILE *const file;
public: public:
ZzipInputStream(const std::shared_ptr<ZzipDir> _dir, const char *_uri, template<typename D>
ZzipInputStream(D &&_dir, const char *_uri,
Mutex &_mutex, Mutex &_mutex,
ZZIP_FILE *_file) ZZIP_FILE *_file)
:InputStream(_uri, _mutex), :InputStream(_uri, _mutex),
dir(_dir), file(_file) { dir(std::forward<D>(_dir)), file(_file) {
//we are seekable (but its not recommendent to do so) //we are seekable (but its not recommendent to do so)
seekable = true; seekable = true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment