mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-01 13:49:16 +00:00
LibWeb: Convert CSS Token::m_unit from StringBuilder to FlyString
This value doesn't change once it's assigned to the Token, so it can be more lightweight than a StringBuilder.
This commit is contained in:
parent
9286aa77bc
commit
75e7c2c5c0
Notes:
sideshowbarker
2024-07-18 00:59:30 +09:00
Author: https://github.com/AtkinsSJ
Commit: 75e7c2c5c0
Pull-request: https://github.com/SerenityOS/serenity/pull/10956
Reviewed-by: https://github.com/alimpfard ✅
3 changed files with 7 additions and 6 deletions
|
@ -59,12 +59,12 @@ String Token::to_debug_string() const
|
|||
case Type::Percentage:
|
||||
builder.append("Percentage: ");
|
||||
builder.append(m_value.to_string());
|
||||
builder.append(m_unit.to_string());
|
||||
builder.append('%');
|
||||
return builder.to_string();
|
||||
case Type::Dimension:
|
||||
builder.append("Dimension: ");
|
||||
builder.append(m_value.to_string());
|
||||
builder.append(m_unit.to_string());
|
||||
builder.append(m_unit);
|
||||
return builder.to_string();
|
||||
case Type::Whitespace:
|
||||
builder.append("Whitespace");
|
||||
|
@ -140,7 +140,7 @@ String Token::to_debug_string() const
|
|||
}
|
||||
|
||||
builder.append("', unit: '");
|
||||
builder.append(m_unit.to_string());
|
||||
builder.append(m_unit);
|
||||
}
|
||||
|
||||
builder.append("' }");
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/FlyString.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <math.h>
|
||||
|
@ -132,7 +133,7 @@ public:
|
|||
StringView dimension_unit() const
|
||||
{
|
||||
VERIFY(m_type == Type::Dimension);
|
||||
return m_unit.string_view();
|
||||
return m_unit.view();
|
||||
}
|
||||
double dimension_value() const
|
||||
{
|
||||
|
@ -175,7 +176,7 @@ private:
|
|||
Type m_type { Type::Invalid };
|
||||
|
||||
StringBuilder m_value;
|
||||
StringBuilder m_unit;
|
||||
FlyString m_unit;
|
||||
HashType m_hash_type { HashType::Unrestricted };
|
||||
NumberType m_number_type { NumberType::Integer };
|
||||
double m_number_value { 0 };
|
||||
|
|
|
@ -685,7 +685,7 @@ Token Tokenizer::consume_a_numeric_token()
|
|||
|
||||
auto unit = consume_a_name();
|
||||
VERIFY(!unit.is_empty() && !unit.is_whitespace());
|
||||
token.m_unit.append(unit);
|
||||
token.m_unit = move(unit);
|
||||
|
||||
return token;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue