mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-31 10:41:08 +00:00
UniValue: add reserve member function
- Only reserve keys when the typ is of `VOBJ`.
This commit is contained in:
parent
bd461195f4
commit
6a506d5c37
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user