From 8de1db7b789432ab70681f498aa97eaa5bc58c02 Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Wed, 3 Jan 2024 13:21:06 -0500 Subject: [PATCH] LibJS: Avoid needless allocation in the StringToNumber AO --- Userland/Libraries/LibJS/Runtime/Value.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Userland/Libraries/LibJS/Runtime/Value.cpp b/Userland/Libraries/LibJS/Runtime/Value.cpp index a17603d5cf..7046483ead 100644 --- a/Userland/Libraries/LibJS/Runtime/Value.cpp +++ b/Userland/Libraries/LibJS/Runtime/Value.cpp @@ -59,7 +59,7 @@ static inline bool same_type_for_equality(Value const& lhs, Value const& rhs) return false; } -static const Crypto::SignedBigInteger BIGINT_ZERO { 0 }; +static Crypto::SignedBigInteger const BIGINT_ZERO { 0 }; ALWAYS_INLINE bool both_number(Value const& lhs, Value const& rhs) { @@ -655,14 +655,14 @@ static Optional parse_number_text(StringView text) double string_to_number(StringView string) { // 1. Let text be StringToCodePoints(str). - ByteString text = Utf8View(string).trim(whitespace_characters, AK::TrimMode::Both).as_string(); + auto text = Utf8View(string).trim(whitespace_characters, AK::TrimMode::Both).as_string(); // 2. Let literal be ParseText(text, StringNumericLiteral). if (text.is_empty()) return 0; - if (text == "Infinity" || text == "+Infinity") + if (text == "Infinity"sv || text == "+Infinity"sv) return INFINITY; - if (text == "-Infinity") + if (text == "-Infinity"sv) return -INFINITY; auto result = parse_number_text(text);