Skip to content

Commit

Permalink
Fix according to coding style guidelines
Browse files Browse the repository at this point in the history
  • Loading branch information
Bill-hbrhbr committed Dec 11, 2024
1 parent 7bd34d2 commit efd2b27
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
16 changes: 10 additions & 6 deletions components/core/src/clp/streaming_compression/lzma/Compressor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -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)};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand Down

0 comments on commit efd2b27

Please sign in to comment.