mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-07 08:39:22 +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
91d6902725
commit
3cc5b1a6a5
Notes:
github-actions[bot]
2025-03-25 23:58:19 +00:00
Author: https://github.com/awesomekling
Commit: 3cc5b1a6a5
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4081
Reviewed-by: https://github.com/AtkinsSJ
Reviewed-by: https://github.com/shannonbooth
1 changed files with 4 additions and 3 deletions
|
@ -107,11 +107,12 @@ private:
|
||||||
{
|
{
|
||||||
if (string_may_be_number != StringMayBeNumber::Yes)
|
if (string_may_be_number != StringMayBeNumber::Yes)
|
||||||
return string;
|
return string;
|
||||||
if (string.is_empty())
|
auto view = string.bytes_as_string_view();
|
||||||
|
if (view.is_empty())
|
||||||
return string;
|
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;
|
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())
|
if (!property_index.has_value() || property_index.value() >= NumericLimits<u32>::max())
|
||||||
return string;
|
return string;
|
||||||
return property_index.release_value();
|
return property_index.release_value();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue