From efd2b2759088c874c2d0a1191b8e4e1d1d16105f Mon Sep 17 00:00:00 2001 From: Bingran Hu Date: Tue, 10 Dec 2024 23:05:31 -0500 Subject: [PATCH] Fix according to coding style guidelines --- .../streaming_compression/lzma/Compressor.cpp | 16 ++++++++++------ .../streaming_compression/lzma/Compressor.hpp | 18 +++++++++--------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/components/core/src/clp/streaming_compression/lzma/Compressor.cpp b/components/core/src/clp/streaming_compression/lzma/Compressor.cpp index 6c4a29206..dc2ca222f 100644 --- a/components/core/src/clp/streaming_compression/lzma/Compressor.cpp +++ b/components/core/src/clp/streaming_compression/lzma/Compressor.cpp @@ -17,18 +17,22 @@ namespace { using clp::streaming_compression::lzma::Compressor; -auto is_flush_action(lzma_action action) -> bool { - return LZMA_SYNC_FLUSH == action || LZMA_FULL_FLUSH == action || LZMA_FULL_BARRIER == action - || LZMA_FINISH == action; -} +auto is_flush_action(lzma_action action) -> bool; /** - * Initialize the LZMA compression stream + * Initializes the LZMA compression stream * @param strm A pre-allocated `lzma_stream` object * @param compression_level * @param dict_size Dictionary size that specifies how many bytes of the * recently processed uncompressed data to keep in the memory */ +auto init_lzma_encoder(lzma_stream* strm, int compression_level, size_t dict_size) -> void; + +auto is_flush_action(lzma_action action) -> bool { + return LZMA_SYNC_FLUSH == action || LZMA_FULL_FLUSH == action || LZMA_FULL_BARRIER == action + || LZMA_FINISH == action; +} + auto init_lzma_encoder(lzma_stream* strm, int compression_level, size_t dict_size) -> void { lzma_options_lzma options; if (0 != lzma_lzma_preset(&options, compression_level)) { @@ -41,7 +45,7 @@ auto init_lzma_encoder(lzma_stream* strm, int compression_level, size_t dict_siz {.id = LZMA_VLI_UNKNOWN, .options = nullptr}, }}; - // Initialize the encoder using a preset. Set the integrity to check to CRC64, which is the + // Initializes the encoder using a preset. Set the integrity to check to CRC64, which is the // default in the xz command line tool. If the .xz file needs to be decompressed with // XZ-Embedded, use LZMA_CHECK_CRC32 instead. auto const rc{lzma_stream_encoder(strm, filters.data(), LZMA_CHECK_CRC64)}; diff --git a/components/core/src/clp/streaming_compression/lzma/Compressor.hpp b/components/core/src/clp/streaming_compression/lzma/Compressor.hpp index 286819893..b4255cc1c 100644 --- a/components/core/src/clp/streaming_compression/lzma/Compressor.hpp +++ b/components/core/src/clp/streaming_compression/lzma/Compressor.hpp @@ -43,6 +43,13 @@ class Compressor : public ::clp::streaming_compression::Compressor { Compressor(Compressor&&) noexcept = default; auto operator=(Compressor&&) noexcept -> Compressor& = default; + /** + * Initializes the compression stream with the given compression level + * @param file_writer + * @param compression_level + */ + auto open(FileWriter& file_writer, int compression_level) -> void; + // Methods implementing the WriterInterface /** * Writes the given data to the compressor @@ -80,18 +87,11 @@ class Compressor : public ::clp::streaming_compression::Compressor { this->open(file_writer, cDefaultCompressionLevel); } - /** - * Initializes the compression stream with the given compression level - * @param file_writer - * @param compression_level - */ - auto open(FileWriter& file_writer, int compression_level) -> void; - private: static constexpr size_t cCompressedStreamBlockBufferSize{4096}; // 4KiB /** - * Invoke lzma_code() repeatedly with LZMA_RUN until the input is exhausted + * Invokes lzma_code() repeatedly with LZMA_RUN until the input is exhausted * * At the end of the workflow, the last bytes of encoded data may still be buffered in the LZMA * stream and thus not immediately available at the output block buffer. @@ -102,7 +102,7 @@ class Compressor : public ::clp::streaming_compression::Compressor { auto encode_lzma() -> void; /** - * Invoke lzma_code() repeatedly with the given flushing action until all encoded data is made + * Invokes lzma_code() repeatedly with the given flushing action until all encoded data is made * available at the output block buffer * * Assumes input stream and output block buffer are both in valid states.