From cb8d2f28ae7127878aea38609cad8d98782eb150 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Mon, 15 Dec 2014 14:43:31 -0800 Subject: [PATCH] Simplify how we set container.nextContainer now that we don't double recurse. --- src/compiler/binder.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 19ee45a419a..4f8141fd866 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -227,23 +227,27 @@ module ts { if (symbolKind & SymbolFlags.HasLocals) { node.locals = {}; } + var saveParent = parent; var saveContainer = container; var savedBlockScopeContainer = blockScopeContainer; parent = node; if (symbolKind & SymbolFlags.IsContainer) { container = node; - // If container is not on container list, add it to the list - if (lastContainer !== container && !container.nextContainer) { - if (lastContainer) { - lastContainer.nextContainer = container; - } - lastContainer = container; + Debug.assert(container.nextContainer === undefined); + + if (lastContainer) { + Debug.assert(lastContainer.nextContainer === undefined); + lastContainer.nextContainer = container; } + + lastContainer = container; } + if (isBlockScopeContainer) { blockScopeContainer = node; } + forEachChild(node, bind); container = saveContainer; parent = saveParent;