mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 15:10:19 +00:00
AK: Allow creating a JsonArray with an initial size
This commit is contained in:
parent
88a4a86ece
commit
c3dfef3861
Notes:
github-actions[bot]
2024-11-03 17:09:09 +00:00
Author: https://github.com/trflynn89 Commit: https://github.com/LadybirdBrowser/ladybird/commit/c3dfef38616 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2137
1 changed files with 6 additions and 0 deletions
|
@ -22,6 +22,11 @@ public:
|
||||||
JsonArray() = default;
|
JsonArray() = default;
|
||||||
~JsonArray() = default;
|
~JsonArray() = default;
|
||||||
|
|
||||||
|
explicit JsonArray(size_t initial_size)
|
||||||
|
{
|
||||||
|
resize(initial_size);
|
||||||
|
}
|
||||||
|
|
||||||
JsonArray(JsonArray const& other)
|
JsonArray(JsonArray const& other)
|
||||||
: m_values(other.m_values)
|
: m_values(other.m_values)
|
||||||
{
|
{
|
||||||
|
@ -93,6 +98,7 @@ public:
|
||||||
[[nodiscard]] Vector<JsonValue> const& values() const { return m_values; }
|
[[nodiscard]] Vector<JsonValue> const& values() const { return m_values; }
|
||||||
|
|
||||||
void ensure_capacity(size_t capacity) { m_values.ensure_capacity(capacity); }
|
void ensure_capacity(size_t capacity) { m_values.ensure_capacity(capacity); }
|
||||||
|
void resize(size_t size) { m_values.resize(size); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Vector<JsonValue> m_values;
|
Vector<JsonValue> m_values;
|
||||||
|
|
Loading…
Reference in a new issue