aboutsummaryrefslogtreecommitdiff
path: root/src/js_parser.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/js_parser.zig')
-rw-r--r--src/js_parser.zig4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/js_parser.zig b/src/js_parser.zig
index f569f515f..3c734bf13 100644
--- a/src/js_parser.zig
+++ b/src/js_parser.zig
@@ -21037,6 +21037,10 @@ fn NewParser_(
// operations, so they should all be child scopes and should all be popped
// by the time we get here.
p.scopes_in_order.items[scope_index] = null;
+ // Decrement the length so that in code with lots of scopes, we use
+ // less memory and do less work
+ p.scopes_in_order.items.len -= @as(usize, @intFromBool(p.scopes_in_order.items.len == scope_index + 1));
+
// Remove the last child from the parent scope
const last = parent.children.len - 1;
if (comptime Environment.allow_assert) assert(parent.children.ptr[last] == to_flatten);