mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 09:57:35 +00:00
LibJS: Use PropertyName instead of StringOrSymbol in Object::invoke()
This prevents the unnecessary PropertyName -> StringOrSymbol -> PropertyName conversion.
This commit is contained in:
parent
fd898be51a
commit
56d8098d13
7 changed files with 16 additions and 16 deletions
|
@ -540,7 +540,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::to_locale_string)
|
|||
auto* value_object = value.to_object(global_object);
|
||||
if (!value_object)
|
||||
return {};
|
||||
auto locale_string_result = value_object->invoke(vm.names.toLocaleString.as_string());
|
||||
auto locale_string_result = value_object->invoke(vm.names.toLocaleString);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
auto string = locale_string_result.to_string(global_object);
|
||||
|
|
|
@ -856,7 +856,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::to_json)
|
|||
if (time_value.is_number() && !time_value.is_finite_number())
|
||||
return js_null();
|
||||
|
||||
return this_object->invoke(vm.names.toISOString.as_string());
|
||||
return this_object->invoke(vm.names.toISOString);
|
||||
}
|
||||
|
||||
// 14.1.1 Date.prototype.toTemporalInstant ( ), https://tc39.es/proposal-temporal/#sec-date.prototype.totemporalinstant
|
||||
|
|
|
@ -1201,7 +1201,7 @@ Value Object::ordinary_to_primitive(Value::PreferredType preferred_type) const
|
|||
return {};
|
||||
}
|
||||
|
||||
Value Object::invoke_internal(const StringOrSymbol& property_name, Optional<MarkedValueList> arguments)
|
||||
Value Object::invoke_internal(PropertyName const& property_name, Optional<MarkedValueList> arguments)
|
||||
{
|
||||
auto& vm = this->vm();
|
||||
auto property = get(property_name);
|
||||
|
|
|
@ -150,10 +150,10 @@ public:
|
|||
IndexedProperties& indexed_properties() { return m_indexed_properties; }
|
||||
void set_indexed_property_elements(Vector<Value>&& values) { m_indexed_properties = IndexedProperties(move(values)); }
|
||||
|
||||
[[nodiscard]] Value invoke_internal(const StringOrSymbol& property_name, Optional<MarkedValueList> arguments);
|
||||
[[nodiscard]] Value invoke_internal(PropertyName const&, Optional<MarkedValueList> arguments);
|
||||
|
||||
template<typename... Args>
|
||||
[[nodiscard]] ALWAYS_INLINE Value invoke(const StringOrSymbol& property_name, Args... args)
|
||||
[[nodiscard]] ALWAYS_INLINE Value invoke(PropertyName const& property_name, Args... args)
|
||||
{
|
||||
if constexpr (sizeof...(Args) > 0) {
|
||||
MarkedValueList arglist { heap() };
|
||||
|
@ -202,12 +202,12 @@ private:
|
|||
};
|
||||
|
||||
template<>
|
||||
[[nodiscard]] ALWAYS_INLINE Value Object::invoke(const StringOrSymbol& property_name, MarkedValueList arguments) { return invoke_internal(property_name, move(arguments)); }
|
||||
[[nodiscard]] ALWAYS_INLINE Value Object::invoke(PropertyName const& property_name, MarkedValueList arguments) { return invoke_internal(property_name, move(arguments)); }
|
||||
|
||||
template<>
|
||||
[[nodiscard]] ALWAYS_INLINE Value Object::invoke(const StringOrSymbol& property_name, Optional<MarkedValueList> arguments) { return invoke_internal(property_name, move(arguments)); }
|
||||
[[nodiscard]] ALWAYS_INLINE Value Object::invoke(PropertyName const& property_name, Optional<MarkedValueList> arguments) { return invoke_internal(property_name, move(arguments)); }
|
||||
|
||||
template<>
|
||||
[[nodiscard]] ALWAYS_INLINE Value Object::invoke(const StringOrSymbol& property_name) { return invoke(property_name, Optional<MarkedValueList> {}); }
|
||||
[[nodiscard]] ALWAYS_INLINE Value Object::invoke(PropertyName const& property_name) { return invoke(property_name, Optional<MarkedValueList> {}); }
|
||||
|
||||
}
|
||||
|
|
|
@ -148,7 +148,7 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectPrototype::to_locale_string)
|
|||
auto* this_object = vm.this_value(global_object).to_object(global_object);
|
||||
if (!this_object)
|
||||
return {};
|
||||
return this_object->invoke(vm.names.toString.as_string());
|
||||
return this_object->invoke(vm.names.toString);
|
||||
}
|
||||
|
||||
// 20.1.3.7 Object.prototype.valueOf ( ), https://tc39.es/ecma262/#sec-object.prototype.valueof
|
||||
|
|
|
@ -71,7 +71,7 @@ JS_DEFINE_NATIVE_FUNCTION(PromisePrototype::catch_)
|
|||
if (!this_object)
|
||||
return {};
|
||||
auto on_rejected = vm.argument(0);
|
||||
return this_object->invoke(vm.names.then.as_string(), js_undefined(), on_rejected);
|
||||
return this_object->invoke(vm.names.then, js_undefined(), on_rejected);
|
||||
}
|
||||
|
||||
// 27.2.5.3 Promise.prototype.finally ( onFinally ), https://tc39.es/ecma262/#sec-promise.prototype.finally
|
||||
|
@ -104,7 +104,7 @@ JS_DEFINE_NATIVE_FUNCTION(PromisePrototype::finally)
|
|||
auto* value_thunk = NativeFunction::create(global_object, "", [value](auto&, auto&) -> Value {
|
||||
return value;
|
||||
});
|
||||
return promise->invoke(vm.names.then.as_string(), value_thunk);
|
||||
return promise->invoke(vm.names.then, value_thunk);
|
||||
});
|
||||
then_finally_function->define_direct_property(vm.names.length, Value(1), Attribute::Configurable);
|
||||
|
||||
|
@ -123,14 +123,14 @@ JS_DEFINE_NATIVE_FUNCTION(PromisePrototype::finally)
|
|||
vm.throw_exception(global_object, reason);
|
||||
return {};
|
||||
});
|
||||
return promise->invoke(vm.names.then.as_string(), thrower);
|
||||
return promise->invoke(vm.names.then, thrower);
|
||||
});
|
||||
catch_finally_function->define_direct_property(vm.names.length, Value(1), Attribute::Configurable);
|
||||
|
||||
then_finally = Value(then_finally_function);
|
||||
catch_finally = Value(catch_finally_function);
|
||||
}
|
||||
return promise->invoke(vm.names.then.as_string(), then_finally, catch_finally);
|
||||
return promise->invoke(vm.names.then, then_finally, catch_finally);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -735,7 +735,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::match)
|
|||
auto rx = regexp_create(global_object, regexp, js_undefined());
|
||||
if (!rx)
|
||||
return {};
|
||||
return rx->invoke(vm.well_known_symbol_match(), js_string(vm, s));
|
||||
return rx->invoke(*vm.well_known_symbol_match(), js_string(vm, s));
|
||||
}
|
||||
|
||||
// 22.1.3.12 String.prototype.matchAll ( regexp ), https://tc39.es/ecma262/#sec-string.prototype.matchall
|
||||
|
@ -775,7 +775,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::match_all)
|
|||
auto rx = regexp_create(global_object, regexp, js_string(vm, "g"));
|
||||
if (!rx)
|
||||
return {};
|
||||
return rx->invoke(vm.well_known_symbol_match_all(), js_string(vm, s));
|
||||
return rx->invoke(*vm.well_known_symbol_match_all(), js_string(vm, s));
|
||||
}
|
||||
|
||||
// 22.1.3.17 String.prototype.replace ( searchValue, replaceValue ), https://tc39.es/ecma262/#sec-string.prototype.replace
|
||||
|
@ -959,7 +959,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::search)
|
|||
auto rx = regexp_create(global_object, regexp, js_undefined());
|
||||
if (!rx)
|
||||
return {};
|
||||
return rx->invoke(vm.well_known_symbol_search(), js_string(vm, s));
|
||||
return rx->invoke(*vm.well_known_symbol_search(), js_string(vm, s));
|
||||
}
|
||||
|
||||
// B.2.3.2.1 CreateHTML ( string, tag, attribute, value ), https://tc39.es/ecma262/#sec-createhtml
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue