Skip to content

Commit

Permalink
[Enhancement] Remove unnecessary frequent memory alloc and release re…
Browse files Browse the repository at this point in the history
…quests (StarRocks#54604)

Signed-off-by: sevev <[email protected]>
  • Loading branch information
sevev authored and magzhu committed Jan 6, 2025
1 parent 24b23d4 commit 270bdf1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions be/src/storage/persistent_index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,11 +233,11 @@ Status ImmutableIndexShard::compress_and_write(const CompressionTypePB& compress
const BlockCompressionCodec* codec = nullptr;
RETURN_IF_ERROR(get_block_compression_codec(compression_type, &codec));
int32_t offset = 0;
faststring compressed_body;
for (int32_t i = 0; i < npage(); i++) {
compressed_body.resize(codec->max_compressed_len(_page_size));
Slice input((uint8_t*)_pages.data() + i * _page_size, _page_size);
*uncompressed_size += input.get_size();
faststring compressed_body;
compressed_body.resize(codec->max_compressed_len(_page_size));
Slice compressed_slice(compressed_body);
RETURN_IF_ERROR(codec->compress(input, &compressed_slice));
RETURN_IF_ERROR(wb.append(compressed_slice));
Expand Down

0 comments on commit 270bdf1

Please sign in to comment.