mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-28 02:27:19 +02:00
LibJS+LibWeb: Reduce use of GlobalObject as an intermediary
- Prefer VM::current_realm() over GlobalObject::associated_realm() - Prefer VM::heap() over GlobalObject::heap() - Prefer Cell::vm() over Cell::global_object() - Prefer Wrapper::vm() over Wrapper::global_object() - Inline Realm::global_object() calls used to access intrinsics as they will later perform a direct lookup without going through the global object
This commit is contained in:
Notes:
sideshowbarker
2024-07-17 07:52:48 +09:00
Author: https://github.com/linusg Commit: https://github.com/SerenityOS/serenity/commit/b345a0acca Pull-request: https://github.com/SerenityOS/serenity/pull/14973 Reviewed-by: https://github.com/davidot ✅
@@ -244,7 +244,6 @@ ThrowCompletionOr<String> format_relative_time(VM& vm, RelativeTimeFormat& relat
|
||||
ThrowCompletionOr<Array*> format_relative_time_to_parts(VM& vm, RelativeTimeFormat& relative_time_format, double value, StringView unit)
|
||||
{
|
||||
auto& realm = *vm.current_realm();
|
||||
auto& global_object = realm.global_object();
|
||||
|
||||
// 1. Let parts be ? PartitionRelativeTimePattern(relativeTimeFormat, value, unit).
|
||||
auto parts = TRY(partition_relative_time_pattern(vm, relative_time_format, value, unit));
|
||||
@@ -258,7 +257,7 @@ ThrowCompletionOr<Array*> format_relative_time_to_parts(VM& vm, RelativeTimeForm
|
||||
// 4. For each Record { [[Type]], [[Value]], [[Unit]] } part in parts, do
|
||||
for (auto& part : parts) {
|
||||
// a. Let O be OrdinaryObjectCreate(%Object.prototype%).
|
||||
auto* object = Object::create(realm, global_object.object_prototype());
|
||||
auto* object = Object::create(realm, realm.global_object().object_prototype());
|
||||
|
||||
// b. Perform ! CreateDataPropertyOrThrow(O, "type", part.[[Type]]).
|
||||
MUST(object->create_data_property_or_throw(vm.names.type, js_string(vm, part.type)));
|
||||
|
||||
Reference in New Issue
Block a user