1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 16:27:35 +00:00

LibWeb: Remove separate Token::m_unit field

Dimension tokens don't make use of the m_value string for anything else,
so we can sneak the unit string in there.

- Token goes from 72 to 64 bytes
- StyleComponentValueRule goes from 80 to 72 bytes
This commit is contained in:
Sam Atkins 2022-03-21 21:04:56 +00:00 committed by Andreas Kling
parent c0d3f1a5e4
commit 13e1232d79
2 changed files with 3 additions and 3 deletions

View file

@ -126,7 +126,7 @@ public:
StringView dimension_unit() const StringView dimension_unit() const
{ {
VERIFY(m_type == Type::Dimension); VERIFY(m_type == Type::Dimension);
return m_unit.view(); return m_value.view();
} }
float dimension_value() const float dimension_value() const
{ {
@ -155,7 +155,6 @@ private:
Type m_type { Type::Invalid }; Type m_type { Type::Invalid };
FlyString m_value; FlyString m_value;
FlyString m_unit;
Number m_number_value; Number m_number_value;
HashType m_hash_type { HashType::Unrestricted }; HashType m_hash_type { HashType::Unrestricted };

View file

@ -845,7 +845,8 @@ Token Tokenizer::consume_a_numeric_token()
// 2. Consume a name. Set the <dimension-token>s unit to the returned value. // 2. Consume a name. Set the <dimension-token>s unit to the returned value.
auto unit = consume_a_name(); auto unit = consume_a_name();
VERIFY(!unit.is_empty()); VERIFY(!unit.is_empty());
token.m_unit = move(unit); // NOTE: We intentionally store this in the `value`, to save space.
token.m_value = move(unit);
// 3. Return the <dimension-token>. // 3. Return the <dimension-token>.
return token; return token;