mirror of
https://github.com/SerenityOS/serenity
synced 2024-07-09 03:47:33 +00:00
LibJS/Bytecode: Apply BigInt/Symbol ToObject avoidance in another place
Same as d667721b2
but in a different place.
This commit is contained in:
parent
d1226f0b15
commit
e1d1aac7bc
|
@ -64,13 +64,19 @@ ALWAYS_INLINE ThrowCompletionOr<NonnullGCPtr<Object>> base_object_for_get(VM& vm
|
|||
return base_value.as_object();
|
||||
|
||||
// OPTIMIZATION: For various primitives we can avoid actually creating a new object for them.
|
||||
auto& realm = *vm.current_realm();
|
||||
if (base_value.is_string())
|
||||
return vm.current_realm()->intrinsics().string_prototype();
|
||||
return realm.intrinsics().string_prototype();
|
||||
if (base_value.is_number())
|
||||
return vm.current_realm()->intrinsics().number_prototype();
|
||||
return realm.intrinsics().number_prototype();
|
||||
if (base_value.is_boolean())
|
||||
return vm.current_realm()->intrinsics().boolean_prototype();
|
||||
return realm.intrinsics().boolean_prototype();
|
||||
if (base_value.is_bigint())
|
||||
return realm.intrinsics().bigint_prototype();
|
||||
if (base_value.is_symbol())
|
||||
return realm.intrinsics().symbol_prototype();
|
||||
|
||||
// NOTE: At this point this is guaranteed to throw (null or undefined).
|
||||
return base_value.to_object(vm);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user