summaryrefslogtreecommitdiff
path: root/AK/JsonParser.cpp
diff options
context:
space:
mode:
authorBrian Gianforcaro <bgianf@serenityos.org>2021-09-15 23:22:56 -0700
committerAndreas Kling <kling@serenityos.org>2021-09-16 17:17:13 +0200
commit14eb736e22c6558941078716c528e5c037545d6e (patch)
tree27e32b5c2eaef6d4fb6ee51293914574b644b42a /AK/JsonParser.cpp
parentc192c303d22a0b4ad698f5ad032527e3f86fbbbf (diff)
downloadserenity-14eb736e22c6558941078716c528e5c037545d6e.zip
AK: Reduce the scope of fraction_string to where it's needed
pvs-studio flagged this a potential optimization, as we only need to really construct the fraction_string if is_double is true.
Diffstat (limited to 'AK/JsonParser.cpp')
-rw-r--r--AK/JsonParser.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/AK/JsonParser.cpp b/AK/JsonParser.cpp
index 4d497cb1b5..fafb6736a6 100644
--- a/AK/JsonParser.cpp
+++ b/AK/JsonParser.cpp
@@ -234,7 +234,6 @@ Optional<JsonValue> JsonParser::parse_number()
}
StringView number_string(number_buffer.data(), number_buffer.size());
- StringView fraction_string(fraction_buffer.data(), fraction_buffer.size());
#ifndef KERNEL
if (is_double) {
@@ -250,6 +249,7 @@ Optional<JsonValue> JsonParser::parse_number()
whole = number.value();
}
+ StringView fraction_string(fraction_buffer.data(), fraction_buffer.size());
auto fraction_string_uint = fraction_string.to_uint();
if (!fraction_string_uint.has_value())
return {};