mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2025-05-11 10:25:47 +02:00
opt: Slightly less allocations in OpaqueObjLoader::CreateHMap (#1227)
Moves the temporary variable outside the loop so we can reuse the buffer. Signed-off-by: Roy Jacobson <roy@dragonflydb.io>
This commit is contained in:
parent
9ff8cdf905
commit
a1a8acb155
1 changed files with 3 additions and 2 deletions
|
@ -596,12 +596,13 @@ void RdbLoaderBase::OpaqueObjLoader::CreateHMap(const LoadTrace* ltrace) {
|
|||
StringMap* string_map = new StringMap;
|
||||
|
||||
auto cleanup = absl::MakeCleanup([&] { delete string_map; });
|
||||
std::string key;
|
||||
string_map->Reserve(len);
|
||||
for (const auto& seg : ltrace->arr) {
|
||||
for (size_t i = 0; i < seg.size(); i += 2) {
|
||||
// ToSV may reference an internal buffer, therefore we can use only before the
|
||||
// next call to ToSV. To workaround, I copy the key to string.
|
||||
string key(ToSV(seg[i].rdb_var));
|
||||
// next call to ToSV. To workaround, copy the key locally.
|
||||
key = ToSV(seg[i].rdb_var);
|
||||
string_view val = ToSV(seg[i + 1].rdb_var);
|
||||
|
||||
if (ec_)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue