mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-27 06:48:49 +00:00
LibJS: Cache a FlyString for "this" to speed up variable lookup
We were hitting strcmp() in every variable lookup to see if the lookup was for "this". Caching a FlyString("this") turns that check into one pointer comparison instead. :^)
This commit is contained in:
parent
26a8984d03
commit
110ca6b0b6
Notes:
sideshowbarker
2024-07-19 07:40:02 +09:00
Author: https://github.com/awesomekling
Commit: 110ca6b0b6
1 changed files with 2 additions and 1 deletions
|
@ -158,7 +158,8 @@ void Interpreter::set_variable(const FlyString& name, Value value, bool first_as
|
|||
|
||||
Optional<Value> Interpreter::get_variable(const FlyString& name)
|
||||
{
|
||||
if (name == "this")
|
||||
static FlyString this_name = "this";
|
||||
if (name == this_name)
|
||||
return this_value();
|
||||
|
||||
for (ssize_t i = m_scope_stack.size() - 1; i >= 0; --i) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue