Remove toLowerCase calls from inner loops, fix #50904

This commit is contained in:
Rob Lourens
2018-06-06 15:32:46 -07:00
parent 3f21188dda
commit ea372c2e0c
+6 -3
View File
@@ -255,7 +255,8 @@ export function matchesCamelCase(word: string, camelCaseWord: string): IMatch[]
let result: IMatch[] = null;
let i = 0;
while (i < camelCaseWord.length && (result = _matchesCamelCase(word.toLowerCase(), camelCaseWord, 0, i)) === null) {
word = word.toLowerCase();
while (i < camelCaseWord.length && (result = _matchesCamelCase(word, camelCaseWord, 0, i)) === null) {
i = nextAnchor(camelCaseWord, i + 1);
}
@@ -275,7 +276,9 @@ export function matchesWords(word: string, target: string, contiguous: boolean =
let result: IMatch[] = null;
let i = 0;
while (i < target.length && (result = _matchesWords(word.toLowerCase(), target, 0, i, contiguous)) === null) {
word = word.toLowerCase();
target = target.toLowerCase();
while (i < target.length && (result = _matchesWords(word, target, 0, i, contiguous)) === null) {
i = nextWord(target, i + 1);
}
@@ -287,7 +290,7 @@ function _matchesWords(word: string, target: string, i: number, j: number, conti
return [];
} else if (j === target.length) {
return null;
} else if (word[i] !== target[j].toLowerCase()) {
} else if (word[i] !== target[j]) {
return null;
} else {
let result: IMatch[] = null;