mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-18 19:40:40 +01:00
UniValue: add reserve member function
- Only reserve keys when the typ is of `VOBJ`.
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user