From c3dfef386166a485e277b5ffbd934d44241eff6b Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Sat, 2 Nov 2024 16:59:27 -0400 Subject: [PATCH] AK: Allow creating a JsonArray with an initial size --- AK/JsonArray.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/AK/JsonArray.h b/AK/JsonArray.h index d85aba3b358..bf00110f7d9 100644 --- a/AK/JsonArray.h +++ b/AK/JsonArray.h @@ -22,6 +22,11 @@ public: JsonArray() = default; ~JsonArray() = default; + explicit JsonArray(size_t initial_size) + { + resize(initial_size); + } + JsonArray(JsonArray const& other) : m_values(other.m_values) { @@ -93,6 +98,7 @@ public: [[nodiscard]] Vector const& values() const { return m_values; } void ensure_capacity(size_t capacity) { m_values.ensure_capacity(capacity); } + void resize(size_t size) { m_values.resize(size); } private: Vector m_values;