From 47fc84784517622be4797be03b79b9c0b22666f1 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Sun, 19 Mar 2023 21:31:49 -0700 Subject: [PATCH] Potentially speed up / lower memory use of getTypeListId --- src/compiler/checker.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index b975b9848853d..fbdac2eae1542 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -15081,7 +15081,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } function getTypeListId(types: readonly Type[] | undefined) { - let result = ""; + let result: string[] | undefined; if (types) { const length = types.length; let i = 0; @@ -15091,17 +15091,16 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { while (i + count < length && types[i + count].id === startId + count) { count++; } - if (result.length) { - result += ","; + if (count === 1) { + result = append(result, `${startId}`); } - result += startId; - if (count > 1) { - result += ":" + count; + else { + result = append(result, `${startId}:${count}`); } i += count; } } - return result; + return result ? result.join(",") : ""; } function getAliasId(aliasSymbol: Symbol | undefined, aliasTypeArguments: readonly Type[] | undefined) {