mirror of
https://github.com/RGBCube/serenity
synced 2025-05-15 07:24:58 +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
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