mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-22 12:35:14 +00:00
LibJS: Do a bit less stuff in PropertyKey::try_coerce_into_number()
The many out-of-line function calls here stood out in a profile.
This commit is contained in:
parent
a9ef5b4924
commit
2c51a2701c
1 changed files with 4 additions and 3 deletions
|
@ -107,11 +107,12 @@ private:
|
|||
{
|
||||
if (string_may_be_number != StringMayBeNumber::Yes)
|
||||
return string;
|
||||
if (string.is_empty())
|
||||
auto view = string.bytes_as_string_view();
|
||||
if (view.is_empty())
|
||||
return string;
|
||||
if (string.bytes_as_string_view().starts_with("0"sv) && string.bytes().size() != 1)
|
||||
if (view[0] == '0' && view.length() > 1)
|
||||
return string;
|
||||
auto property_index = string.bytes_as_string_view().to_number<u32>(TrimWhitespace::No);
|
||||
auto property_index = view.to_number<u32>(TrimWhitespace::No);
|
||||
if (!property_index.has_value() || property_index.value() >= NumericLimits<u32>::max())
|
||||
return string;
|
||||
return property_index.release_value();
|
||||
|
|
Loading…
Add table
Reference in a new issue