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.
This commit is contained in:
Brian Gianforcaro 2021-09-15 23:22:56 -07:00 committed by Andreas Kling
parent c192c303d2
commit 14eb736e22

View file

@ -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 {};