mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-10 13:00:29 +03:00
LibJS: Tweak Value::to_property_key() fast path for Int32
Move the check for Int32 *before* we call to_primitive().
This commit is contained in:
parent
cfbb69a9cd
commit
72cd31d033
Notes:
sideshowbarker
2024-07-18 01:53:16 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/72cd31d0338
@ -561,9 +561,9 @@ ThrowCompletionOr<double> Value::to_double(GlobalObject& global_object) const
|
||||
// 7.1.19 ToPropertyKey ( argument ), https://tc39.es/ecma262/#sec-topropertykey
|
||||
ThrowCompletionOr<PropertyKey> Value::to_property_key(GlobalObject& global_object) const
|
||||
{
|
||||
if (type() == Type::Int32 && as_i32() >= 0)
|
||||
return PropertyKey { as_i32() };
|
||||
auto key = TRY(to_primitive(global_object, PreferredType::String));
|
||||
if (key.type() == Type::Int32 && key.as_i32() >= 0)
|
||||
return PropertyKey { key.as_i32() };
|
||||
if (key.is_symbol())
|
||||
return &key.as_symbol();
|
||||
return TRY(key.to_string(global_object));
|
||||
|
Loading…
Reference in New Issue
Block a user