Skip to content

Commit

Permalink
Remove unused scope from Walker
Browse files Browse the repository at this point in the history
The `scope` info here is entirely unused in the Glimmer codebase. It may
be used in some AST transforms, but this is fairly unlikely, since it
has only been available since Ember 3.16. Profiling template compilation
highlighted the recursive walking of the whole tree for locals in scope
during syntax parsing as a major cost in CPU usage, so the hope is that
removing this will help.
  • Loading branch information
chriskrycho committed Oct 22, 2021
1 parent e57c5e0 commit 8efb85e
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 215 deletions.
16 changes: 0 additions & 16 deletions packages/@glimmer/syntax/lib/traversal/path.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import * as ASTv1 from '../v1/api';
import RootTransformScope, { TransformScope } from './scope';

export default class WalkerPath<N extends ASTv1.Node> {
node: N;
parent: WalkerPath<ASTv1.Node> | null;
parentKey: string | null;
scope: TransformScope;

constructor(
node: N,
Expand All @@ -15,20 +13,6 @@ export default class WalkerPath<N extends ASTv1.Node> {
this.node = node;
this.parent = parent;
this.parentKey = parentKey;
this.scope = parent ? parent.scope.child(node) : new RootTransformScope(node);

// Consume in scope values
if (node.type === 'PathExpression') {
this.scope.useLocal(node);
}

if (node.type === 'ElementNode') {
this.scope.useLocal(node);

(node as ASTv1.ElementNode).children.forEach((node: ASTv1.Statement) =>
this.scope.useLocal(node)
);
}
}

get parentNode(): ASTv1.Node | null {
Expand Down
138 changes: 0 additions & 138 deletions packages/@glimmer/syntax/lib/traversal/scope.ts

This file was deleted.

61 changes: 0 additions & 61 deletions packages/@glimmer/syntax/test/traversal/scope-test.ts

This file was deleted.

0 comments on commit 8efb85e

Please sign in to comment.