Make 'getIndentString' just use a loop. (#41221)

* Make 'getIndentString' just use a loop.

* Added test.

* Accepted baselines.
This commit is contained in:
Daniel Rosenwasser
2020-10-26 12:19:31 -07:00
committed by GitHub
parent 6c298474e4
commit 3517af8f80
5 changed files with 51 additions and 2 deletions

View File

@@ -3849,8 +3849,10 @@ namespace ts {
const indentStrings: string[] = ["", " "];
export function getIndentString(level: number) {
if (indentStrings[level] === undefined) {
indentStrings[level] = getIndentString(level - 1) + indentStrings[1];
// prepopulate cache
const singleLevel = indentStrings[1];
for (let current = indentStrings.length; current <= level; current++) {
indentStrings.push(indentStrings[current - 1] + singleLevel);
}
return indentStrings[level];
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long