Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Bingran Hu <[email protected]>
  • Loading branch information
davidlion and Bill-hbrhbr authored Dec 20, 2024
1 parent 50c8e89 commit d139bd5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
15 changes: 3 additions & 12 deletions components/core/src/clp/streaming_compression/lzma/Compressor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ auto Compressor::open(FileWriter& file_writer) -> void {
m_compressed_stream_block_buffer.size()
))
{
throw OperationFailed(ErrorCode_NotReady, __FILENAME__, __LINE__);
throw OperationFailed(ErrorCode_NotInit, __FILENAME__, __LINE__);
}
m_compressed_stream_file_writer = &file_writer;
m_uncompressed_stream_pos = 0;
Expand All @@ -52,20 +52,11 @@ auto Compressor::write(char const* data, size_t data_length) -> void {
if (nullptr == m_compressed_stream_file_writer) {
throw OperationFailed(ErrorCode_NotInit, __FILENAME__, __LINE__);
}

if (0 == data_length) {
return;
}

if (nullptr == data) {
throw OperationFailed(ErrorCode_BadParam, __FILENAME__, __LINE__);
}

if (false
== m_lzma_stream
.attach_input(clp::size_checked_pointer_cast<uint8_t const>(data), data_length))
{
throw OperationFailed(ErrorCode_NotReady, __FILENAME__, __LINE__);
throw OperationFailed(ErrorCode_BadParam, __FILENAME__, __LINE__);
}
encode_lzma();
m_lzma_stream.detach_input();
Expand Down Expand Up @@ -164,7 +155,7 @@ auto Compressor::flush_stream_output_block_buffer() -> void {
m_compressed_stream_block_buffer.size()
))
{
throw OperationFailed(ErrorCode_NotReady, __FILENAME__, __LINE__);
throw OperationFailed(ErrorCode_NotInit, __FILENAME__, __LINE__);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ class Compressor : public ::clp::streaming_compression::Compressor {
}
};

// Constructor
// Constructors
Compressor() : Compressor{cDefaultCompressionLevel, cDefaultDictionarySize, LZMA_CHECK_CRC64} {}
Compressor(int compression_level, size_t dict_size, lzma_check check)
: m_lzma_stream{compression_level, dict_size, check} {}

Expand Down

0 comments on commit d139bd5

Please sign in to comment.