improve filter/score speed a little by avoiding uncessary string-creation, #10621
This commit is contained in:
parent
eb068a5d4e
commit
2d93ffc8e2
1 changed files with 11 additions and 4 deletions
|
@ -78,16 +78,23 @@ export class CompletionModel {
|
||||||
private _filterAndScore(): void {
|
private _filterAndScore(): void {
|
||||||
this._filteredItems = [];
|
this._filteredItems = [];
|
||||||
this._topScoreIdx = -1;
|
this._topScoreIdx = -1;
|
||||||
let topScore = -1;
|
|
||||||
const {leadingLineContent, characterCountDelta} = this._lineContext;
|
const {leadingLineContent, characterCountDelta} = this._lineContext;
|
||||||
|
|
||||||
//TODO@joh - sort by 'overwriteBefore' such that we can 'reuse' the word (wordLowerCase)
|
let word = '';
|
||||||
|
let topScore = -1;
|
||||||
|
|
||||||
for (const item of this._items) {
|
for (const item of this._items) {
|
||||||
|
|
||||||
const start = leadingLineContent.length - (item.suggestion.overwriteBefore + characterCountDelta);
|
|
||||||
const word = leadingLineContent.substr(start);
|
|
||||||
const {filter, suggestion} = item;
|
const {filter, suggestion} = item;
|
||||||
|
|
||||||
|
// 'word' is that remainder of the current line that we
|
||||||
|
// filter and score against. In theory each suggestion uses a
|
||||||
|
// differnet word, but in practice not - that's why we cache
|
||||||
|
const wordLen = item.suggestion.overwriteBefore + characterCountDelta;
|
||||||
|
if (word.length !== wordLen) {
|
||||||
|
word = leadingLineContent.slice(-wordLen);
|
||||||
|
}
|
||||||
|
|
||||||
let match = false;
|
let match = false;
|
||||||
|
|
||||||
// compute highlights based on 'label'
|
// compute highlights based on 'label'
|
||||||
|
|
Loading…
Reference in a new issue