More removals.

This commit is contained in:
Daniel Rosenwasser 2021-11-06 09:33:40 +00:00 committed by GitHub
parent 044de3ec63
commit e64dbabab8
6 changed files with 12 additions and 28 deletions

View file

@ -288,14 +288,6 @@ namespace ts {
return result;
}
export function getNodeIdOrDefault(node: Node): number {
return idCache.get(node) || 0;
}
export function setNodeIdForStrangeRedirect(node: Node, id: number): void {
idCache.set(node, id);
}
export function getSymbolId(symbol: Symbol): SymbolId {
if (!symbol.id) {
symbol.id = nextSymbolId;
@ -971,7 +963,7 @@ namespace ts {
let flowInvocationCount = 0;
let lastFlowNode: FlowNode | undefined;
let lastFlowNodeReachable: boolean;
let flowTypeCache: Type[] | undefined;
let flowTypeCache: ESMap<Node, Type> | undefined;
const emptyStringType = getStringLiteralType("");
const zeroType = getNumberLiteralType(0);
@ -3899,10 +3891,9 @@ namespace ts {
function getAlternativeContainingModules(symbol: Symbol, enclosingDeclaration: Node): Symbol[] {
const containingFile = getSourceFileOfNode(enclosingDeclaration);
const id = getNodeId(containingFile);
const links = getSymbolLinks(symbol);
let results: Symbol[] | undefined;
if (links.extendedContainersByFile && (results = links.extendedContainersByFile.get(id))) {
if (links.extendedContainersByFile && (results = links.extendedContainersByFile.get(containingFile))) {
return results;
}
if (containingFile && containingFile.imports) {
@ -3916,7 +3907,7 @@ namespace ts {
results = append(results, resolvedModule);
}
if (length(results)) {
(links.extendedContainersByFile || (links.extendedContainersByFile = new Map())).set(id, results!);
(links.extendedContainersByFile ||= new Map()).set(containingFile, results!);
return results!;
}
}
@ -33799,7 +33790,7 @@ namespace ts {
}
// If a type has been cached for the node, return it.
if (node.flags & NodeFlags.TypeCached && flowTypeCache) {
const cachedType = flowTypeCache[getNodeId(node)];
const cachedType = flowTypeCache.get(node);
if (cachedType) {
return cachedType;
}
@ -33808,8 +33799,8 @@ namespace ts {
const type = checkExpression(node);
// If control flow analysis was required to determine the type, it is worth caching.
if (flowInvocationCount !== startInvocationCount) {
const cache = flowTypeCache || (flowTypeCache = []);
cache[getNodeId(node)] = type;
const cache = (flowTypeCache ||= new Map<Node, Type>());
cache.set(node, type);
setNodeFlags(node, node.flags | NodeFlags.TypeCached);
}
return type;
@ -41612,9 +41603,6 @@ namespace ts {
}
function getNodeCheckFlags(node: Node): NodeCheckFlags {
// TODO: probably not meaningful, right?
// const nodeId = getNodeIdOrDefault(node);
// if (nodeId < 0 || nodeId >= nodeLinks.length) return 0;
return nodeLinks.get(node)?.flags || 0;
}

View file

@ -5339,7 +5339,7 @@ namespace ts {
}
function flattenCommaElements(node: Expression): Expression | readonly Expression[] {
if (nodeIsSynthesized(node) && !isParseTreeNode(node) && !node.original && !node.emitNode && !getNodeIdOrDefault(node)) {
if (nodeIsSynthesized(node) && !isParseTreeNode(node) && !node.original && !node.emitNode) {
if (isCommaListExpression(node)) {
return node.elements;
}

View file

@ -2592,10 +2592,6 @@ namespace ts {
redirect.redirectInfo = { redirectTarget, unredirected };
sourceFilesFoundSearchingNodeModules.set(path, currentNodeModulesDepth > 0);
Object.defineProperties(redirect, {
id: {
get(this: SourceFile) { return getNodeIdOrDefault(this.redirectInfo!.redirectTarget); },
set(this: SourceFile, value: number) { setNodeIdForStrangeRedirect(this.redirectInfo!.redirectTarget, value); },
},
symbol: {
get(this: SourceFile) { return this.redirectInfo!.redirectTarget.symbol; },
set(this: SourceFile, value: SourceFile["symbol"]) { this.redirectInfo!.redirectTarget.symbol = value; },

View file

@ -64,7 +64,7 @@ namespace ts {
*/
function onSubstituteNode(hint: EmitHint, node: Node) {
// TODO: do we need to check for a Node ID here?
if (getNodeIdOrDefault(node) && noSubstitution?.has(node)) {
if (noSubstitution?.has(node)) {
return previousOnSubstituteNode(hint, node);
}

View file

@ -698,7 +698,7 @@ namespace ts {
}
if (temp) {
noSubstitution.add(expression);;
noSubstitution.add(expression);
expression = factory.createComma(expression, temp);
setTextRange(expression, node);
}
@ -1852,7 +1852,7 @@ namespace ts {
function substituteCallExpression(node: CallExpression) {
if (isIdentifier(node.expression)) {
const expression = substituteExpressionIdentifier(node.expression);
noSubstitution.add(expression);;
noSubstitution.add(expression);
if (!isIdentifier(expression)) {
return addEmitFlags(
factory.updateCallExpression(node,
@ -1962,7 +1962,7 @@ namespace ts {
let expression: Expression = node;
for (const exportName of exportedNames) {
// Mark the node to prevent triggering this rule again.
noSubstitution.add(expression);;
noSubstitution.add(expression);
expression = createExportExpression(exportName, expression, /*location*/ node);
}

View file

@ -4945,7 +4945,7 @@ namespace ts {
lateSymbol?: Symbol; // Late-bound symbol for a computed property
specifierCache?: ESMap<string, string>; // For symbols corresponding to external modules, a cache of incoming path -> module specifier name mappings
extendedContainers?: Symbol[]; // Containers (other than the parent) which this symbol is aliased in
extendedContainersByFile?: ESMap<NodeId, Symbol[]>; // Containers (other than the parent) which this symbol is aliased in
extendedContainersByFile?: ESMap<Node, Symbol[]>; // Containers (other than the parent) which this symbol is aliased in
variances?: VarianceFlags[]; // Alias symbol type argument variance cache
deferralConstituents?: Type[]; // Calculated list of constituents for a deferred type
deferralParent?: Type; // Source union/intersection of a deferred type