mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 16:38:05 -06:00
Make 'getIndentString' just use a loop. (#41221)
* Make 'getIndentString' just use a loop. * Added test. * Accepted baselines.
This commit is contained in:
parent
6c298474e4
commit
3517af8f80
@ -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
Loading…
x
Reference in New Issue
Block a user