From 19ff269602c190feef5a815cbeb6f760fcdd328b Mon Sep 17 00:00:00 2001 From: Marcus Holland-Moritz Date: Wed, 9 Apr 2025 14:15:05 +0200 Subject: [PATCH] refactor(incompressible_categorizer): use `internal::malloc_buffer` --- .../categorizer/incompressible_categorizer.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/writer/categorizer/incompressible_categorizer.cpp b/src/writer/categorizer/incompressible_categorizer.cpp index b3d65472..d70ea282 100644 --- a/src/writer/categorizer/incompressible_categorizer.cpp +++ b/src/writer/categorizer/incompressible_categorizer.cpp @@ -25,7 +25,6 @@ #include #include #include -#include #include @@ -39,6 +38,8 @@ #include #include +#include + namespace dwarfs::writer { namespace po = boost::program_options; @@ -125,10 +126,8 @@ class incompressible_categorizer_job_ : public sequential_categorizer_job { private: void add_input(std::span data) { - auto current_size = input_.size(); - assert(current_size + data.size() <= cfg_.block_size); - input_.resize(current_size + data.size()); - ::memcpy(&input_[current_size], data.data(), data.size()); + assert(input_.size() + data.size() <= cfg_.block_size); + input_.append(data.data(), data.size()); if (input_.size() == cfg_.block_size) { compress(); } @@ -187,8 +186,8 @@ class incompressible_categorizer_job_ : public sequential_categorizer_job { } LOG_PROXY_DECL(LoggerPolicy); - std::vector input_; - std::vector output_; + dwarfs::internal::malloc_buffer input_; + dwarfs::internal::malloc_buffer output_; size_t total_input_size_{0}; size_t total_output_size_{0}; size_t total_blocks_{0};