Remove redundant call to checkNodeDeferred (#22516)

* Remove redundant call to `checkNodeDeferred`

* Use a set to speed up `contains` checks
This commit is contained in:
Andy
2018-03-13 15:46:25 -07:00
committed by GitHub
parent e41feab3bd
commit 23a64fe804
3 changed files with 13 additions and 11 deletions

View File

@@ -422,6 +422,7 @@ namespace ts {
let deferredNodes: Node[];
let deferredUnusedIdentifierNodes: Node[];
const seenDeferredUnusedIdentifiers = createMap<true>(); // For assertion that we don't defer the same identifier twice
let flowLoopStart = 0;
let flowLoopCount = 0;
@@ -18674,7 +18675,6 @@ namespace ts {
// The identityMapper object is used to indicate that function expressions are wildcards
if (checkMode === CheckMode.SkipContextSensitive && isContextSensitive(node)) {
checkNodeDeferred(node);
return anyFunctionType;
}
@@ -21564,6 +21564,7 @@ namespace ts {
function registerForUnusedIdentifiersCheck(node: Node) {
if (deferredUnusedIdentifierNodes) {
Debug.assert(addToSeen(seenDeferredUnusedIdentifiers, getNodeId(node)), "Deferring unused identifier check twice");
deferredUnusedIdentifierNodes.push(node);
}
}
@@ -24573,6 +24574,7 @@ namespace ts {
}
deferredNodes = undefined;
seenDeferredUnusedIdentifiers.clear();
deferredUnusedIdentifierNodes = undefined;
if (isExternalOrCommonJsModule(node)) {

View File

@@ -3839,6 +3839,16 @@ namespace ts {
export function showModuleSpecifier({ moduleSpecifier }: ImportDeclaration): string {
return isStringLiteral(moduleSpecifier) ? moduleSpecifier.text : getTextOfNode(moduleSpecifier);
}
/** Add a value to a set, and return true if it wasn't already present. */
export function addToSeen(seen: Map<true>, key: string | number): boolean {
key = String(key);
if (seen.has(key)) {
return false;
}
seen.set(key, true);
return true;
}
}
namespace ts {

View File

@@ -1205,16 +1205,6 @@ namespace ts {
};
}
/** Add a value to a set, and return true if it wasn't already present. */
export function addToSeen(seen: Map<true>, key: string | number): boolean {
key = String(key);
if (seen.has(key)) {
return false;
}
seen.set(key, true);
return true;
}
export function getSnapshotText(snap: IScriptSnapshot): string {
return snap.getText(0, snap.getLength());
}