Cosmetic changes: * Pass compression dictionaries by value. They are represented as `SharedPtr` or `std::vector` at the toplevel. * Fix `ZlibDictionary::set_data()`: do not convert through NUL-terminated `const char*`. * Fix typos. PiperOrigin-RevId: 914720638
diff --git a/riegeli/brotli/brotli_dictionary.h b/riegeli/brotli/brotli_dictionary.h index ed69277..a902e36 100644 --- a/riegeli/brotli/brotli_dictionary.h +++ b/riegeli/brotli/brotli_dictionary.h
@@ -133,7 +133,7 @@ // `BrotliEncoderPreparedDictionary` pointer. It can be used for compression // but not for decompression. // - // Does not take ownedship of `prepared, which must be valid until the last + // Does not take ownership of `prepared, which must be valid until the last // `BrotliReader` or `BrotliWriter` using this dictionary is closed or no // longer used. BrotliDictionary& add_native_unowned(
diff --git a/riegeli/brotli/brotli_reader.h b/riegeli/brotli/brotli_reader.h index 7aa0b8a..7b3813c 100644 --- a/riegeli/brotli/brotli_reader.h +++ b/riegeli/brotli/brotli_reader.h
@@ -108,14 +108,14 @@ protected: explicit BrotliReaderBase(Closed) noexcept : PullableReader(kClosed) {} - explicit BrotliReaderBase(BrotliDictionary&& dictionary, - BrotliAllocator&& allocator); + explicit BrotliReaderBase(BrotliDictionary dictionary, + BrotliAllocator allocator); BrotliReaderBase(BrotliReaderBase&& that) noexcept; BrotliReaderBase& operator=(BrotliReaderBase&& that) noexcept; void Reset(Closed); - void Reset(BrotliDictionary&& dictionary, BrotliAllocator&& allocator); + void Reset(BrotliDictionary dictionary, BrotliAllocator allocator); void Initialize(Reader* src); ABSL_ATTRIBUTE_COLD absl::Status AnnotateOverSrc(absl::Status status); @@ -211,8 +211,8 @@ // Implementation details follow. -inline BrotliReaderBase::BrotliReaderBase(BrotliDictionary&& dictionary, - BrotliAllocator&& allocator) +inline BrotliReaderBase::BrotliReaderBase(BrotliDictionary dictionary, + BrotliAllocator allocator) : dictionary_(std::move(dictionary)), allocator_(std::move(allocator)) {} inline BrotliReaderBase::BrotliReaderBase(BrotliReaderBase&& that) noexcept @@ -245,8 +245,8 @@ allocator_ = BrotliAllocator(); } -inline void BrotliReaderBase::Reset(BrotliDictionary&& dictionary, - BrotliAllocator&& allocator) { +inline void BrotliReaderBase::Reset(BrotliDictionary dictionary, + BrotliAllocator allocator) { PullableReader::Reset(); initial_compressed_pos_ = 0; truncated_ = false;
diff --git a/riegeli/brotli/brotli_writer.h b/riegeli/brotli/brotli_writer.h index 2a5e16e..a1737a4 100644 --- a/riegeli/brotli/brotli_writer.h +++ b/riegeli/brotli/brotli_writer.h
@@ -162,15 +162,15 @@ explicit BrotliWriterBase(Closed) noexcept : BufferedWriter(kClosed) {} explicit BrotliWriterBase(BufferOptions buffer_options, - BrotliDictionary&& dictionary, - BrotliAllocator&& allocator); + BrotliDictionary dictionary, + BrotliAllocator allocator); BrotliWriterBase(BrotliWriterBase&& that) noexcept; BrotliWriterBase& operator=(BrotliWriterBase&& that) noexcept; void Reset(Closed); - void Reset(BufferOptions buffer_options, BrotliDictionary&& dictionary, - BrotliAllocator&& allocator); + void Reset(BufferOptions buffer_options, BrotliDictionary dictionary, + BrotliAllocator allocator); void Initialize(Writer* dest, int compression_level, int window_log); ABSL_ATTRIBUTE_COLD absl::Status AnnotateOverDest(absl::Status status); @@ -262,8 +262,8 @@ // Implementation details follow. inline BrotliWriterBase::BrotliWriterBase(BufferOptions buffer_options, - BrotliDictionary&& dictionary, - BrotliAllocator&& allocator) + BrotliDictionary dictionary, + BrotliAllocator allocator) : BufferedWriter(buffer_options), dictionary_(std::move(dictionary)), allocator_(std::move(allocator)) {} @@ -299,8 +299,8 @@ } inline void BrotliWriterBase::Reset(BufferOptions buffer_options, - BrotliDictionary&& dictionary, - BrotliAllocator&& allocator) { + BrotliDictionary dictionary, + BrotliAllocator allocator) { BufferedWriter::Reset(buffer_options); initial_compressed_pos_ = 0; compressor_.reset();
diff --git a/riegeli/bytes/fd_writer.cc b/riegeli/bytes/fd_writer.cc index af2272d..4666d65 100644 --- a/riegeli/bytes/fd_writer.cc +++ b/riegeli/bytes/fd_writer.cc
@@ -237,7 +237,7 @@ } else { // `fd_internal::LSeek(SEEK_CUR)` succeeded, and // `fd_internal::LSeek(SEEK_END)` will be checked later. - // `supports_random_access_` and `supports_read_mode_` are left as + // `supports_random_access_` and `supports_read_mode_` are left as // `LazyBoolState::kUnknown`. } }
diff --git a/riegeli/bytes/reader_istream.h b/riegeli/bytes/reader_istream.h index a0d23e0..9615e70 100644 --- a/riegeli/bytes/reader_istream.h +++ b/riegeli/bytes/reader_istream.h
@@ -324,7 +324,9 @@ }; template <typename Src> -inline ReaderIStream<Src>::ReaderIStream(Initializer<Src> src, Options options) +inline ReaderIStream<Src>::ReaderIStream(Initializer<Src> src, + Options /*options*/ + ) : src_(std::move(src)) { Initialize(src_.get()); } @@ -336,7 +338,8 @@ } template <typename Src> -inline void ReaderIStream<Src>::Reset(Initializer<Src> src, Options options) { +inline void ReaderIStream<Src>::Reset(Initializer<Src> src, Options /*options*/ +) { ReaderIStreamBase::Reset(); src_.Reset(std::move(src)); Initialize(src_.get());
diff --git a/riegeli/bytes/writer_ostream.h b/riegeli/bytes/writer_ostream.h index e24db9e..71bafde 100644 --- a/riegeli/bytes/writer_ostream.h +++ b/riegeli/bytes/writer_ostream.h
@@ -332,7 +332,8 @@ template <typename Dest> inline WriterOStream<Dest>::WriterOStream(Initializer<Dest> dest, - Options options) + Options /*options*/ + ) : dest_(std::move(dest)) { Initialize(dest_.get()); } @@ -345,7 +346,8 @@ template <typename Dest> inline void WriterOStream<Dest>::Reset(Initializer<Dest> dest, - Options options) { + Options /*options*/ +) { WriterOStreamBase::Reset(); dest_.Reset(std::move(dest)); Initialize(dest_.get());
diff --git a/riegeli/lz4/lz4_reader.h b/riegeli/lz4/lz4_reader.h index c4167f0..536b128 100644 --- a/riegeli/lz4/lz4_reader.h +++ b/riegeli/lz4/lz4_reader.h
@@ -170,7 +170,7 @@ explicit Lz4ReaderBase(Closed) noexcept : BufferedReader(kClosed) {} explicit Lz4ReaderBase(BufferOptions buffer_options, bool growing_source, - bool concatenate, Lz4Dictionary&& dictionary, + bool concatenate, Lz4Dictionary dictionary, RecyclingPoolOptions recycling_pool_options); Lz4ReaderBase(Lz4ReaderBase&& that) noexcept; @@ -178,7 +178,7 @@ void Reset(Closed); void Reset(BufferOptions buffer_options, bool growing_source, - bool concatenate, Lz4Dictionary&& dictionary, + bool concatenate, Lz4Dictionary dictionary, RecyclingPoolOptions recycling_pool_options); void Initialize(Reader* src); ABSL_ATTRIBUTE_COLD absl::Status AnnotateOverSrc(absl::Status status); @@ -308,7 +308,7 @@ inline Lz4ReaderBase::Lz4ReaderBase(BufferOptions buffer_options, bool growing_source, bool concatenate, - Lz4Dictionary&& dictionary, + Lz4Dictionary dictionary, RecyclingPoolOptions recycling_pool_options) : BufferedReader(buffer_options), growing_source_(growing_source), @@ -354,7 +354,7 @@ inline void Lz4ReaderBase::Reset(BufferOptions buffer_options, bool growing_source, bool concatenate, - Lz4Dictionary&& dictionary, + Lz4Dictionary dictionary, RecyclingPoolOptions recycling_pool_options) { BufferedReader::Reset(buffer_options); growing_source_ = growing_source;
diff --git a/riegeli/lz4/lz4_writer.h b/riegeli/lz4/lz4_writer.h index ea3883d..cd66bb5 100644 --- a/riegeli/lz4/lz4_writer.h +++ b/riegeli/lz4/lz4_writer.h
@@ -260,8 +260,7 @@ protected: explicit Lz4WriterBase(Closed) noexcept : BufferedWriter(kClosed) {} - explicit Lz4WriterBase(BufferOptions buffer_options, - Lz4Dictionary&& dictionary, + explicit Lz4WriterBase(BufferOptions buffer_options, Lz4Dictionary dictionary, std::optional<Position> pledged_size, bool reserve_max_size, RecyclingPoolOptions recycling_pool_options); @@ -270,7 +269,7 @@ Lz4WriterBase& operator=(Lz4WriterBase&& that) noexcept; void Reset(Closed); - void Reset(BufferOptions buffer_options, Lz4Dictionary&& dictionary, + void Reset(BufferOptions buffer_options, Lz4Dictionary dictionary, std::optional<Position> pledged_size, bool reserve_max_size, RecyclingPoolOptions recycling_pool_options); void Initialize(Writer* dest, int compression_level, int window_log, @@ -281,7 +280,7 @@ ABSL_ATTRIBUTE_COLD absl::Status AnnotateStatusImpl( absl::Status status) override; bool WriteInternal(absl::string_view src) override; - bool FlushImpl(FlushType flush_type); + bool FlushImpl(FlushType flush_type) override; Reader* ReadModeBehindBuffer(Position initial_pos) override; private: @@ -376,7 +375,7 @@ // Implementation details follow. inline Lz4WriterBase::Lz4WriterBase(BufferOptions buffer_options, - Lz4Dictionary&& dictionary, + Lz4Dictionary dictionary, std::optional<Position> pledged_size, bool reserve_max_size, RecyclingPoolOptions recycling_pool_options) @@ -430,7 +429,7 @@ } inline void Lz4WriterBase::Reset(BufferOptions buffer_options, - Lz4Dictionary&& dictionary, + Lz4Dictionary dictionary, std::optional<Position> pledged_size, bool reserve_max_size, RecyclingPoolOptions recycling_pool_options) {
diff --git a/riegeli/snappy/framed/framed_snappy_reader.h b/riegeli/snappy/framed/framed_snappy_reader.h index ed3632b..21d1a8e 100644 --- a/riegeli/snappy/framed/framed_snappy_reader.h +++ b/riegeli/snappy/framed/framed_snappy_reader.h
@@ -38,7 +38,13 @@ // Template parameter independent part of `FramedSnappyReader`. class FramedSnappyReaderBase : public PullableReader { public: - class Options {}; + class Options { + public: + Options() noexcept {} + + Options(const Options& that) = default; + Options& operator=(const Options& that) = default; + }; // Returns the compressed `Reader`. Unchanged by `Close()`. virtual Reader* SrcReader() const ABSL_ATTRIBUTE_LIFETIME_BOUND = 0;
diff --git a/riegeli/snappy/hadoop/hadoop_snappy_reader.h b/riegeli/snappy/hadoop/hadoop_snappy_reader.h index 7a9b232..eb7c1b9 100644 --- a/riegeli/snappy/hadoop/hadoop_snappy_reader.h +++ b/riegeli/snappy/hadoop/hadoop_snappy_reader.h
@@ -38,7 +38,13 @@ // Template parameter independent part of `HadoopSnappyReader`. class HadoopSnappyReaderBase : public PullableReader { public: - class Options {}; + class Options { + public: + Options() noexcept {} + + Options(const Options& that) = default; + Options& operator=(const Options& that) = default; + }; // Returns the compressed `Reader`. Unchanged by `Close()`. virtual Reader* SrcReader() const ABSL_ATTRIBUTE_LIFETIME_BOUND = 0;
diff --git a/riegeli/zlib/zlib_dictionary.h b/riegeli/zlib/zlib_dictionary.h index a6c3f9f..fc9a72c 100644 --- a/riegeli/zlib/zlib_dictionary.h +++ b/riegeli/zlib/zlib_dictionary.h
@@ -100,7 +100,7 @@ inline ZlibDictionary& ZlibDictionary::set_data(BytesInitializer data) & ABSL_ATTRIBUTE_LIFETIME_BOUND { owned_data_.Reset(std::move(data)); - data_ = owned_data_->data(); + data_ = *owned_data_; return *this; }
diff --git a/riegeli/zlib/zlib_reader.h b/riegeli/zlib/zlib_reader.h index b85ddca..42639c9 100644 --- a/riegeli/zlib/zlib_reader.h +++ b/riegeli/zlib/zlib_reader.h
@@ -188,7 +188,7 @@ explicit ZlibReaderBase(Closed) noexcept : BufferedReader(kClosed) {} explicit ZlibReaderBase(BufferOptions buffer_options, int window_bits, - bool concatenate, ZlibDictionary&& dictionary, + bool concatenate, ZlibDictionary dictionary, RecyclingPoolOptions recycling_pool_options); ZlibReaderBase(ZlibReaderBase&& that) noexcept; @@ -196,7 +196,7 @@ void Reset(Closed); void Reset(BufferOptions buffer_options, int window_bits, bool concatenate, - ZlibDictionary&& dictionary, + ZlibDictionary dictionary, RecyclingPoolOptions recycling_pool_options); static int GetWindowBits(const Options& options); void Initialize(Reader* src); @@ -334,7 +334,7 @@ inline ZlibReaderBase::ZlibReaderBase( BufferOptions buffer_options, int window_bits, bool concatenate, - ZlibDictionary&& dictionary, RecyclingPoolOptions recycling_pool_options) + ZlibDictionary dictionary, RecyclingPoolOptions recycling_pool_options) : BufferedReader(buffer_options), window_bits_(window_bits), concatenate_(concatenate), @@ -380,7 +380,7 @@ } inline void ZlibReaderBase::Reset(BufferOptions buffer_options, int window_bits, - bool concatenate, ZlibDictionary&& dictionary, + bool concatenate, ZlibDictionary dictionary, RecyclingPoolOptions recycling_pool_options) { BufferedReader::Reset(buffer_options); window_bits_ = window_bits;
diff --git a/riegeli/zlib/zlib_writer.h b/riegeli/zlib/zlib_writer.h index ebfa756..95b3629 100644 --- a/riegeli/zlib/zlib_writer.h +++ b/riegeli/zlib/zlib_writer.h
@@ -183,7 +183,7 @@ explicit ZlibWriterBase(Closed) noexcept : BufferedWriter(kClosed) {} explicit ZlibWriterBase(BufferOptions buffer_options, int window_bits, - ZlibDictionary&& dictionary, + ZlibDictionary dictionary, RecyclingPoolOptions recycling_pool_options); ZlibWriterBase(ZlibWriterBase&& that) noexcept; @@ -191,7 +191,7 @@ void Reset(Closed); void Reset(BufferOptions buffer_options, int window_bits, - ZlibDictionary&& dictionary, + ZlibDictionary dictionary, RecyclingPoolOptions recycling_pool_options); static int GetWindowBits(const Options& options); void Initialize(Writer* dest, int compression_level); @@ -305,7 +305,7 @@ // Implementation details follow. inline ZlibWriterBase::ZlibWriterBase( - BufferOptions buffer_options, int window_bits, ZlibDictionary&& dictionary, + BufferOptions buffer_options, int window_bits, ZlibDictionary dictionary, RecyclingPoolOptions recycling_pool_options) : BufferedWriter(buffer_options), window_bits_(window_bits), @@ -345,7 +345,7 @@ } inline void ZlibWriterBase::Reset(BufferOptions buffer_options, int window_bits, - ZlibDictionary&& dictionary, + ZlibDictionary dictionary, RecyclingPoolOptions recycling_pool_options) { BufferedWriter::Reset(buffer_options); window_bits_ = window_bits;
diff --git a/riegeli/zstd/zstd_reader.h b/riegeli/zstd/zstd_reader.h index fb62205..db33665 100644 --- a/riegeli/zstd/zstd_reader.h +++ b/riegeli/zstd/zstd_reader.h
@@ -158,7 +158,7 @@ explicit ZstdReaderBase(Closed) noexcept : BufferedReader(kClosed) {} explicit ZstdReaderBase(BufferOptions buffer_options, bool growing_source, - bool concatenate, ZstdDictionary&& dictionary, + bool concatenate, ZstdDictionary dictionary, RecyclingPoolOptions recycling_pool_options); ZstdReaderBase(ZstdReaderBase&& that) noexcept; @@ -166,7 +166,7 @@ void Reset(Closed); void Reset(BufferOptions buffer_options, bool growing_source, - bool concatenate, ZstdDictionary&& dictionary, + bool concatenate, ZstdDictionary dictionary, RecyclingPoolOptions recycling_pool_options); void Initialize(Reader* src); ABSL_ATTRIBUTE_COLD absl::Status AnnotateOverSrc(absl::Status status); @@ -289,7 +289,7 @@ inline ZstdReaderBase::ZstdReaderBase( BufferOptions buffer_options, bool growing_source, bool concatenate, - ZstdDictionary&& dictionary, RecyclingPoolOptions recycling_pool_options) + ZstdDictionary dictionary, RecyclingPoolOptions recycling_pool_options) : BufferedReader(buffer_options), growing_source_(growing_source), concatenate_(concatenate), @@ -335,7 +335,7 @@ inline void ZstdReaderBase::Reset(BufferOptions buffer_options, bool growing_source, bool concatenate, - ZstdDictionary&& dictionary, + ZstdDictionary dictionary, RecyclingPoolOptions recycling_pool_options) { BufferedReader::Reset(buffer_options); growing_source_ = growing_source;
diff --git a/riegeli/zstd/zstd_writer.h b/riegeli/zstd/zstd_writer.h index 84d0ab7..ccbb801 100644 --- a/riegeli/zstd/zstd_writer.h +++ b/riegeli/zstd/zstd_writer.h
@@ -291,7 +291,7 @@ explicit ZstdWriterBase(Closed) noexcept : BufferedWriter(kClosed) {} explicit ZstdWriterBase(BufferOptions buffer_options, - ZstdDictionary&& dictionary, + ZstdDictionary dictionary, std::optional<Position> pledged_size, bool reserve_max_size, RecyclingPoolOptions recycling_pool_options); @@ -300,7 +300,7 @@ ZstdWriterBase& operator=(ZstdWriterBase&& that) noexcept; void Reset(Closed); - void Reset(BufferOptions buffer_options, ZstdDictionary&& dictionary, + void Reset(BufferOptions buffer_options, ZstdDictionary dictionary, std::optional<Position> pledged_size, bool reserve_max_size, RecyclingPoolOptions recycling_pool_options); void Initialize(Writer* dest, int compression_level, int window_log_or_0, @@ -398,7 +398,7 @@ // Implementation details follow. inline ZstdWriterBase::ZstdWriterBase( - BufferOptions buffer_options, ZstdDictionary&& dictionary, + BufferOptions buffer_options, ZstdDictionary dictionary, std::optional<Position> pledged_size, bool reserve_max_size, RecyclingPoolOptions recycling_pool_options) : BufferedWriter(buffer_options), @@ -446,7 +446,7 @@ } inline void ZstdWriterBase::Reset(BufferOptions buffer_options, - ZstdDictionary&& dictionary, + ZstdDictionary dictionary, std::optional<Position> pledged_size, bool reserve_max_size, RecyclingPoolOptions recycling_pool_options) {