mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 03:17:35 +00:00
LibJS: Add Token::flystring_value() to produce FlyString directly
When parsing identifiers, we ultimately want to sink the token string into a FlyString anyway, and since Token may have a FlyString already inside it, this allows us to bypass the costly FlyString(StringView). This gives a ~3% speedup when parsing the largest Discord JS file.
This commit is contained in:
parent
515594c667
commit
0cb0979990
2 changed files with 20 additions and 11 deletions
|
@ -210,6 +210,15 @@ public:
|
|||
[](FlyString const& identifier) { return identifier.view(); },
|
||||
[](Empty) -> StringView { VERIFY_NOT_REACHED(); });
|
||||
}
|
||||
|
||||
FlyString flystring_value() const
|
||||
{
|
||||
return m_value.visit(
|
||||
[](StringView view) -> FlyString { return view; },
|
||||
[](FlyString const& identifier) -> FlyString { return identifier; },
|
||||
[](Empty) -> FlyString { VERIFY_NOT_REACHED(); });
|
||||
}
|
||||
|
||||
StringView filename() const { return m_filename; }
|
||||
size_t line_number() const { return m_line_number; }
|
||||
size_t line_column() const { return m_line_column; }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue