LibWeb: Avoid FlyString lookups when setting IDL interface prototypes

This commit introduces a WEB_SET_PROTOTYPE_FOR_INTERFACE macro that
caches the interface name in a local static FlyString. This means that
we only pay for FlyString-from-literal lookup once per browser lifetime
instead of every time the interface is instantiated.
This commit is contained in:
Andreas Kling 2024-03-16 13:13:08 +01:00
commit c0d7f748ed
Notes: sideshowbarker 2024-07-16 22:11:09 +09:00
284 changed files with 291 additions and 283 deletions

View file

@ -146,7 +146,7 @@ Blob::~Blob() = default;
void Blob::initialize(JS::Realm& realm)
{
Base::initialize(realm);
set_prototype(&Bindings::ensure_web_prototype<Bindings::BlobPrototype>(realm, "Blob"_fly_string));
WEB_SET_PROTOTYPE_FOR_INTERFACE(Blob);
}
WebIDL::ExceptionOr<void> Blob::serialization_steps(HTML::SerializationRecord& record, bool)

View file

@ -29,7 +29,7 @@ File::File(JS::Realm& realm)
void File::initialize(JS::Realm& realm)
{
Base::initialize(realm);
set_prototype(&Bindings::ensure_web_prototype<Bindings::FilePrototype>(realm, "File"_fly_string));
WEB_SET_PROTOTYPE_FOR_INTERFACE(File);
}
File::~File() = default;

View file

@ -30,7 +30,7 @@ FileList::~FileList() = default;
void FileList::initialize(JS::Realm& realm)
{
Base::initialize(realm);
set_prototype(&Bindings::ensure_web_prototype<Bindings::FileListPrototype>(realm, "FileList"_fly_string));
WEB_SET_PROTOTYPE_FOR_INTERFACE(FileList);
}
// https://w3c.github.io/FileAPI/#dfn-item

View file

@ -42,7 +42,7 @@ FileReader::FileReader(JS::Realm& realm)
void FileReader::initialize(JS::Realm& realm)
{
Base::initialize(realm);
set_prototype(&Bindings::ensure_web_prototype<Bindings::FileReaderPrototype>(realm, "FileReader"_fly_string));
WEB_SET_PROTOTYPE_FOR_INTERFACE(FileReader);
}
void FileReader::visit_edges(JS::Cell::Visitor& visitor)