perf(addon-search): avoid repeated substring allocation in reverse regex
Hoist searchStringLine.slice(0, offset) outside the reverse regex exec loop. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -288,7 +288,8 @@ export class SearchEngine {
|
||||
let foundTerm: RegExpExecArray | null;
|
||||
if (isReverseSearch) {
|
||||
// This loop will get the resultIndex of the _last_ regex match in the range 0..offset
|
||||
while (foundTerm = searchRegex.exec(searchStringLine.slice(0, offset))) {
|
||||
const searchSubstring = searchStringLine.slice(0, offset);
|
||||
while (foundTerm = searchRegex.exec(searchSubstring)) {
|
||||
if (foundTerm[0].length === 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user