1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 06:48:12 +00:00

LibWeb: Compress specificity into a 32-bit unsigned int

Instead of storing the three-part specificy for every selector,
just mash them together into a 32-bit value instead.
This saves both space and time, and matches the behavior of other
browser engines.
This commit is contained in:
Andreas Kling 2020-06-25 16:43:49 +02:00
parent 8be74ea65c
commit 49dd4b7e8a
4 changed files with 6 additions and 68 deletions

View file

@ -37,7 +37,7 @@ Selector::~Selector()
{
}
Specificity Selector::specificity() const
u32 Selector::specificity() const
{
unsigned ids = 0;
unsigned tag_names = 0;
@ -61,7 +61,7 @@ Specificity Selector::specificity() const
}
}
return { ids, classes, tag_names };
return ids * 0x10000 + classes * 0x100 + tag_names;
}
}