mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 14:48:14 +00:00
LibWeb: Use HTML::AttributeNames::foo instead of FlyString("foo")
To avoid the costly instantiation of FlyStrings whenever we're looking up attributes, use the premade HTML::AttributeNames globals. :^)
This commit is contained in:
parent
ff55d00261
commit
2149820260
16 changed files with 71 additions and 43 deletions
|
@ -30,22 +30,30 @@ namespace Web {
|
|||
namespace HTML {
|
||||
namespace AttributeNames {
|
||||
|
||||
FlyString id;
|
||||
FlyString class_;
|
||||
FlyString type;
|
||||
FlyString href;
|
||||
FlyString style;
|
||||
#define __ENUMERATE_HTML_ATTRIBUTE(name) FlyString name;
|
||||
ENUMERATE_HTML_ATTRIBUTES
|
||||
#undef __ENUMERATE_HTML_ATTRIBUTE
|
||||
|
||||
void initialize()
|
||||
{
|
||||
static bool s_initialized = false;
|
||||
if (s_initialized)
|
||||
return;
|
||||
|
||||
#define __ENUMERATE_HTML_ATTRIBUTE(name) \
|
||||
name = #name; \
|
||||
if (name.ends_with("_")) \
|
||||
name = name.view().substring_view(0, name.length() - 1);
|
||||
ENUMERATE_HTML_ATTRIBUTES
|
||||
#undef __ENUMERATE_HTML_ATTRIBUTE
|
||||
|
||||
id = "id";
|
||||
class_ = "class";
|
||||
type = "type";
|
||||
href = "href";
|
||||
style = "style";
|
||||
name = "name";
|
||||
|
||||
s_initialized = true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue