mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 00:50:22 +00:00
JsonObject: Add move constructors for JsonObject(Json{Array,Object}&&)
This also helps avoid JsonValue copying during parse.
This commit is contained in:
parent
82826104e0
commit
93596dc00d
Notes:
sideshowbarker
2024-07-19 12:54:13 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/93596dc00db
2 changed files with 19 additions and 0 deletions
|
@ -127,6 +127,18 @@ JsonValue::JsonValue(const JsonArray& value)
|
|||
m_value.as_array = new JsonArray(value);
|
||||
}
|
||||
|
||||
JsonValue::JsonValue(JsonObject&& value)
|
||||
: m_type(Type::Object)
|
||||
{
|
||||
m_value.as_object = new JsonObject(move(value));
|
||||
}
|
||||
|
||||
JsonValue::JsonValue(JsonArray&& value)
|
||||
: m_type(Type::Array)
|
||||
{
|
||||
m_value.as_array = new JsonArray(move(value));
|
||||
}
|
||||
|
||||
void JsonValue::clear()
|
||||
{
|
||||
switch (m_type) {
|
||||
|
|
|
@ -50,6 +50,13 @@ public:
|
|||
JsonValue(const JsonArray&);
|
||||
JsonValue(const JsonObject&);
|
||||
|
||||
JsonValue(JsonArray&&);
|
||||
JsonValue(JsonObject&&);
|
||||
|
||||
// FIXME: Implement these
|
||||
JsonValue& operator=(JsonArray&&) = delete;
|
||||
JsonValue& operator=(JsonObject&&) = delete;
|
||||
|
||||
String serialized() const;
|
||||
void serialize(StringBuilder&) const;
|
||||
|
||||
|
|
Loading…
Reference in a new issue