diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-08-04 11:45:16 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-08-04 11:45:16 +0200 |
commit | 82826104e07b62dcc1f4fdbb612082df6532ebb5 (patch) | |
tree | 037e0be1bc23baae8ec6e22199fb7d7ad4479124 /AK/JsonObject.h | |
parent | cce2ea9bb018f39b0e41b865b35a9b66e55075b2 (diff) | |
download | serenity-82826104e07b62dcc1f4fdbb612082df6532ebb5.zip |
Json: Add efficient copy and move constructors for Json{Array,Object}
This helps avoid copying JsonValues during parsing.
Diffstat (limited to 'AK/JsonObject.h')
-rw-r--r-- | AK/JsonObject.h | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/AK/JsonObject.h b/AK/JsonObject.h index 2796db1c53..a21e9f03c3 100644 --- a/AK/JsonObject.h +++ b/AK/JsonObject.h @@ -9,7 +9,31 @@ namespace AK { class JsonObject { public: JsonObject() { } - ~JsonObject() { } + ~JsonObject() {} + + JsonObject(const JsonObject& other) + : m_members(other.m_members) + { + } + + JsonObject(JsonObject&& other) + : m_members(move(other.m_members)) + { + } + + JsonObject& operator=(const JsonObject& other) + { + if (this != &other) + m_members = other.m_members; + return *this; + } + + JsonObject& operator=(JsonObject&& other) + { + if (this != &other) + m_members = move(other.m_members); + return *this; + } int size() const { return m_members.size(); } bool is_empty() const { return m_members.is_empty(); } |