Simplify how we set container.nextContainer now that we don't double recurse.

This commit is contained in:
Cyrus Najmabadi 2014-12-15 14:43:31 -08:00
parent 9bb6cee923
commit cb8d2f28ae

View File

@ -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;