Grab function directly to avoid possible .call overhead from downlevel emit.

This commit is contained in:
Daniel Rosenwasser
2022-08-09 22:06:21 +00:00
parent 6269b365a2
commit b94b82a896
+4 -4
View File
@@ -97,9 +97,8 @@ namespace ts {
type ForEachChildFunction = <T>(node: any, cbNode: (node: Node) => T | undefined, cbNodes?: (nodes: NodeArray<Node>) => T | undefined) => T | undefined;
const forEachChildTable: ForEachChildFunction[] = [];
const forEachChildNoOpFn: ForEachChildFunction = (_node, _cbNode, _cbNodes) => undefined;
for (let i = 0; i < SyntaxKind.Count; i++) forEachChildTable.push(forEachChildNoOpFn);
const forEachChildTable: (ForEachChildFunction | undefined)[] = [];
for (let i = 0; i < SyntaxKind.Count; i++) forEachChildTable.push(undefined);
forEachChildTable[SyntaxKind.QualifiedName] = forEachChildInQualifiedName;
forEachChildTable[SyntaxKind.TypeParameter] = forEachChildInTypeParameter;
forEachChildTable[SyntaxKind.ShorthandPropertyAssignment] = forEachChildInShorthandPropertyAssignment;
@@ -1088,7 +1087,8 @@ namespace ts {
return;
}
return forEachChildTable[node.kind](node, cbNode, cbNodes);
const fn = forEachChildTable[node.kind];
return fn === undefined ? undefined : fn(node, cbNode, cbNodes);
}
/** @internal */