UniValue: add reserve member function

- Only reserve keys when the typ is of `VOBJ`.
This commit is contained in:
ismaelsadeeq committed 2025-01-22 17:31:22 -05:00
1 parent bd461195f4
commit 6a506d5c37
2 files changed
+9

No files matched your search

+2
View File
@@ -70,6 +70,8 @@ public:
size_t size() const { return values.size(); }
void reserve(size_t new_cap);
void getObjMap(std::map<std::string,UniValue>& kv) const;
bool checkObject(const std::map<std::string,UniValue::VType>& memberTypes) const;
const UniValue& operator[](const std::string& key) const;
+7
View File
@@ -240,3 +240,10 @@ const UniValue& UniValue::find_value(std::string_view key) const
return NullUniValue;
}
void UniValue::reserve(size_t new_cap)
{
values.reserve(new_cap);
if (typ == VOBJ) {
keys.reserve(new_cap);
}
}