From d603b0e8f02eac1db41ef1c30cd8d7a41521e797 Mon Sep 17 00:00:00 2001 From: BradLee Date: Thu, 22 Jul 2021 18:43:44 +0800 Subject: [PATCH] Fix:avoid useless space allocation in SetBit --- src/redis_bitmap.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/redis_bitmap.cc b/src/redis_bitmap.cc index da6e3abf1d2..7e8a95bd8b0 100644 --- a/src/redis_bitmap.cc +++ b/src/redis_bitmap.cc @@ -106,6 +106,8 @@ rocksdb::Status Bitmap::SetBit(const Slice &user_key, uint32_t offset, bool new_ size_t expand_size; if (byte_index >= value.size() * 2) { expand_size = byte_index - value.size() + 1; + } else if (value.size() * 2 > kBitmapSegmentBytes) { + expand_size = kBitmapSegmentBytes - value.size(); } else { expand_size = value.size(); }