LibJS: Stop lazily coercing numeric PropertyKeys

Lazily coercing might have made sense in the past, but since hashing
and comparing requires the `PropertyKey` to be coerced, and since a
`PropertyKey` will be used to index into a hashmap 99% of the time,
which will hash the `PropertyKey` and use it in comparisons, the
extra complexity and branching produced by lazily coercing has
become more trouble than it is worth.

Remove the lazy coercions, which then also neatly allows us to
switch to a `Variant`-based implementation.
This commit is contained in:
Jonne Ransijn 2024-12-01 00:37:09 +01:00 committed by Andreas Kling
commit cfb00ba494
Notes: github-actions[bot] 2024-12-01 09:43:49 +00:00
4 changed files with 59 additions and 126 deletions

View file

@ -156,7 +156,7 @@ static WebIDL::ExceptionOr<KeyframeType<AL>> process_a_keyframe_like_object(JS::
auto name = input_property.as_string().utf8_string();
if (name == "all"sv) {
all_value = TRY(keyframe_object.get(JS::PropertyKey { name }));
all_value = TRY(keyframe_object.get(JS::PropertyKey { "all"sv }));
for (auto i = to_underlying(CSS::first_longhand_property_id); i <= to_underlying(CSS::last_longhand_property_id); ++i) {
auto property = static_cast<CSS::PropertyID>(i);
if (CSS::is_animatable_property(property))
@ -183,7 +183,7 @@ static WebIDL::ExceptionOr<KeyframeType<AL>> process_a_keyframe_like_object(JS::
// 1. Let raw value be the result of calling the [[Get]] internal method on keyframe input, with property name
// as the property key and keyframe input as the receiver.
// 2. Check the completion record of raw value.
JS::PropertyKey key { property_name };
JS::PropertyKey key { property_name.to_byte_string() };
auto raw_value = TRY(keyframe_object.has_property(key)) ? TRY(keyframe_object.get(key)) : *all_value;
using PropertyValuesType = Conditional<AL == AllowLists::Yes, Vector<String>, String>;