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

Spreadsheet: Don't recreate the global environment on every evaluation

The worksheet's realm does not change, and is not shared, so we can
safely leave the global environment be.
This fixes lexical scoping in the spreadsheet's runtime file.
This commit is contained in:
Ali Mohammad Pur 2021-11-21 03:33:17 +03:30 committed by Ali Mohammad Pur
parent 398f1ca842
commit 892e585e9a

View file

@ -166,9 +166,6 @@ Sheet::ValueAndException Sheet::evaluate(StringView source, Cell* on_behalf_of)
if (parser.has_errors() || interpreter().exception()) if (parser.has_errors() || interpreter().exception())
return { JS::js_undefined(), interpreter().exception() }; return { JS::js_undefined(), interpreter().exception() };
// FIXME: This creates a GlobalEnvironment for every evaluate call which we might be able to circumvent with multiple realms.
interpreter().realm().set_global_object(global_object(), &global_object());
interpreter().run(global_object(), program); interpreter().run(global_object(), program);
if (interpreter().exception()) { if (interpreter().exception()) {
auto exc = interpreter().exception(); auto exc = interpreter().exception();