mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-17 01:49:57 -05:00
Remove redundant call to checkNodeDeferred (#22516)
* Remove redundant call to `checkNodeDeferred` * Use a set to speed up `contains` checks
This commit is contained in:
@@ -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)) {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user