LibWeb: Cache name->element mappings in HTMLCollection

This makes https://wpt.fyi/ load today instead of tomorrow, although
there's a lot of room for improvement still.
This commit is contained in:
Andreas Kling 2024-07-25 07:49:41 +02:00 committed by Andreas Kling
commit 4d78c66b3d
Notes: github-actions[bot] 2024-07-25 11:12:56 +00:00
4 changed files with 48 additions and 31 deletions

View file

@ -47,9 +47,7 @@ JS::ThrowCompletionOr<bool> PlatformObject::is_named_property_exposed_on_object(
// 1. If P is not a supported property name of O, then return false.
// NOTE: This is in it's own variable to enforce the type.
auto supported_property_names = this->supported_property_names();
auto property_key_string = MUST(String::from_byte_string(property_key.to_string()));
if (!supported_property_names.contains_slow(property_key_string))
if (!is_supported_property_name(MUST(String::from_byte_string(property_key.to_string()))))
return false;
// 2. If O has an own property named P, then return false.
@ -500,6 +498,11 @@ Vector<FlyString> PlatformObject::supported_property_names() const
return {};
}
bool PlatformObject::is_supported_property_name(FlyString const& name) const
{
return supported_property_names().contains_slow(name);
}
bool PlatformObject::is_supported_property_index(u32) const
{
return false;