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
parent 6de4f75d32
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

@ -118,7 +118,7 @@ Variant<GC::Ref<DOM::HTMLCollection>, GC::Ref<DOM::Element>, Empty> HTMLAllColle
return Empty {};
// 2. Return the result of getting the "all"-indexed or named element(s) from this, given nameOrIndex.
return get_the_all_indexed_or_named_elements(name_or_index.value());
return get_the_all_indexed_or_named_elements(name_or_index.value().to_deprecated_fly_string());
}
// https://html.spec.whatwg.org/multipage/common-dom-interfaces.html#dom-htmlallcollection-nameditem