From 39bb669dcb430ab52e335b8a156b53f179a24430 Mon Sep 17 00:00:00 2001 From: stdpain <34912776+stdpain@users.noreply.github.com> Date: Fri, 10 Sep 2021 09:52:41 +0800 Subject: [PATCH] [BUG] fix extra memory copy in bitmap value (#6599) --- be/src/util/bitmap_value.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/be/src/util/bitmap_value.h b/be/src/util/bitmap_value.h index 52f39c5bac..e3a0208207 100644 --- a/be/src/util/bitmap_value.h +++ b/be/src/util/bitmap_value.h @@ -616,7 +616,7 @@ public: if (*buf == BitmapTypeCode::BITMAP32) { Roaring read = Roaring::read(buf + 1); - result.emplaceOrInsert(0, read); + result.emplaceOrInsert(0, std::move(read)); return result; } @@ -635,9 +635,9 @@ public: buf += sizeof(uint32_t); // read map value Roaring Roaring read = Roaring::read(buf); - result.emplaceOrInsert(key, read); // forward buffer past the last Roaring Bitmap buf += read.getSizeInBytes(); + result.emplaceOrInsert(key, std::move(read)); } return result; } @@ -846,6 +846,10 @@ private: roarings.emplace(std::make_pair(key, value)); #endif } + + void emplace(const uint32_t key, Roaring&& value) { + roarings.emplace(std::make_pair(key, std::move(value))); + } }; // Forked from https://github.com/RoaringBitmap/CRoaring/blob/v0.2.60/cpp/roaring64map.hh