summaryrefslogtreecommitdiff
path: root/AK/JsonParser.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-05-14 11:54:43 +0200
committerAndreas Kling <kling@serenityos.org>2021-05-14 11:54:43 +0200
commitfccfc33dfbcfad58e7e3a3493ad73f813495b034 (patch)
treeabd04675e295e465603d0f7c1b7233fa95b95eb4 /AK/JsonParser.cpp
parent6210d2612ebf690800e8bf59b41218da784acba8 (diff)
downloadserenity-fccfc33dfbcfad58e7e3a3493ad73f813495b034.zip
AK: Use move semantics to avoid copying in JSON parser
The JSON parser was deep-copying JsonValues left and right, and it was all totally avoidable. :^)
Diffstat (limited to 'AK/JsonParser.cpp')
-rw-r--r--AK/JsonParser.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/AK/JsonParser.cpp b/AK/JsonParser.cpp
index bb9d52b0e7..80d1794c26 100644
--- a/AK/JsonParser.cpp
+++ b/AK/JsonParser.cpp
@@ -98,7 +98,7 @@ Optional<JsonValue> JsonParser::parse_object()
auto value = parse_helper();
if (!value.has_value())
return {};
- object.set(name, move(value.value()));
+ object.set(name, value.release_value());
ignore_while(isspace);
if (peek() == '}')
break;
@@ -110,7 +110,7 @@ Optional<JsonValue> JsonParser::parse_object()
}
if (!consume_specific('}'))
return {};
- return object;
+ return JsonValue { move(object) };
}
Optional<JsonValue> JsonParser::parse_array()
@@ -125,7 +125,7 @@ Optional<JsonValue> JsonParser::parse_array()
auto element = parse_helper();
if (!element.has_value())
return {};
- array.append(element.value());
+ array.append(element.release_value());
ignore_while(isspace);
if (peek() == ']')
break;
@@ -138,7 +138,7 @@ Optional<JsonValue> JsonParser::parse_array()
ignore_while(isspace);
if (!consume_specific(']'))
return {};
- return array;
+ return JsonValue { move(array) };
}
Optional<JsonValue> JsonParser::parse_string()