1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 07:58:11 +00:00

LibWeb: Add cached global attribute name FlyStrings

Instead of creating extremely common FlyStrings like "id" and "class"
on demand every time they are needed, we now have AttributeNames.h,
which provides Web::HTML::AttributeNames::{id,class_}

This avoids a bunch of string allocations during selector matching.
This commit is contained in:
Andreas Kling 2020-05-26 23:27:22 +02:00
parent 5069d380a8
commit 82444048de
7 changed files with 102 additions and 5 deletions

View file

@ -37,6 +37,7 @@
#include <LibWeb/Bindings/WindowObject.h>
#include <LibWeb/CSS/SelectorEngine.h>
#include <LibWeb/CSS/StyleResolver.h>
#include <LibWeb/DOM/AttributeNames.h>
#include <LibWeb/DOM/Document.h>
#include <LibWeb/DOM/DocumentType.h>
#include <LibWeb/DOM/Element.h>
@ -65,6 +66,8 @@ Document::Document(const URL& url)
, m_url(url)
, m_window(Window::create_with_document(*this))
{
HTML::AttributeNames::initialize();
m_style_update_timer = Core::Timer::create_single_shot(0, [this] {
update_style();
});