Use native maps when they're available

This commit is contained in:
Andy Hanson
2016-10-06 13:29:18 -07:00
parent 3212e25a3a
commit aadcbcc083
66 changed files with 1678 additions and 1326 deletions
+2 -6
View File
@@ -113,7 +113,7 @@ namespace ts {
// we see the name of a module that is used everywhere, or the name of an overload). As
// such, we cache the information we compute about the candidate for the life of this
// pattern matcher so we don't have to compute it multiple times.
const stringToWordSpans = createMap<TextSpan[]>();
const stringToWordSpans = new StringMap<TextSpan[]>();
pattern = pattern.trim();
@@ -188,11 +188,7 @@ namespace ts {
}
function getWordSpans(word: string): TextSpan[] {
if (!(word in stringToWordSpans)) {
stringToWordSpans[word] = breakIntoWordSpans(word);
}
return stringToWordSpans[word];
return getOrUpdate(stringToWordSpans, word, breakIntoWordSpans);
}
function matchTextChunk(candidate: string, chunk: TextChunk, punctuationStripped: boolean): PatternMatch {