[BUG] fix extra memory copy in bitmap value (#6599)

This commit is contained in:
stdpain
2021-09-10 09:52:41 +08:00
committed by GitHub
parent 4f744333c2
commit 39bb669dcb

View File

@ -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