1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 02:17: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:
Idan Horowitz 2021-07-09 23:45:01 +03:00 committed by Linus Groh
parent fd898be51a
commit 56d8098d13
7 changed files with 16 additions and 16 deletions

View file

@ -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> {}); }
}