From 2877d55db17be70d9b55fd728c9024586e2d8a1e Mon Sep 17 00:00:00 2001 From: Marcus Holland-Moritz Date: Mon, 15 Mar 2021 10:34:23 +0100 Subject: [PATCH] Clean up block manager code --- src/dwarfs/block_manager.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/dwarfs/block_manager.cpp b/src/dwarfs/block_manager.cpp index 9ac4faaa..7edc5928 100644 --- a/src/dwarfs/block_manager.cpp +++ b/src/dwarfs/block_manager.cpp @@ -283,7 +283,9 @@ class block_manager_ final : public block_manager::impl { cfg.window_increment_shift)} , block_size_{static_cast(1) << cfg.block_size_bits} , filter_{bloom_filter_size()} { - LOG_INFO << "bloom filter size: " << size_with_unit(filter_.size() / 8); + if (segmentation_enabled()) { + LOG_INFO << "bloom filter size: " << size_with_unit(filter_.size() / 8); + } } void add_inode(std::shared_ptr ino) override; @@ -295,6 +297,10 @@ class block_manager_ final : public block_manager::impl { size_t size{0}; }; + bool segmentation_enabled() const { + return cfg_.max_active_blocks > 0 and window_size_ > 0; + } + void block_ready(); void finish_chunk(inode& ino); void append_to_block(inode& ino, mmif& mm, size_t offset, size_t size); @@ -423,8 +429,7 @@ void block_manager_::add_inode(std::shared_ptr ino) { LOG_TRACE << "adding inode " << ino->num() << " [" << ino->any()->name() << "] - size: " << size; - if (cfg_.max_active_blocks == 0 or window_size_ == 0 or - size < window_size_) { + if (!segmentation_enabled() or size < window_size_) { // no point dealing with hashing, just write it out add_data(*ino, *mm, 0, size); finish_chunk(*ino);