mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-01-17 01:35:37 -05:00
Optimized parsers for speed & memory usage
Switches to lazy parsing of diff chunks
This commit is contained in:
@@ -43,6 +43,19 @@ export namespace Strings {
|
||||
return new Function(`return \`${template}\`;`).call(context);
|
||||
}
|
||||
|
||||
export function* lines(s: string): IterableIterator<string> {
|
||||
let i = 0;
|
||||
while (i < s.length) {
|
||||
let j = s.indexOf('\n', i);
|
||||
if (j === -1) {
|
||||
j = s.length;
|
||||
}
|
||||
|
||||
yield s.substring(i, j);
|
||||
i = j + 1;
|
||||
}
|
||||
}
|
||||
|
||||
export function padLeft(s: string, padTo: number, padding: string = '\u00a0') {
|
||||
const diff = padTo - s.length;
|
||||
return (diff <= 0) ? s : '\u00a0'.repeat(diff) + s;
|
||||
|
||||
Reference in New Issue
Block a user