diff options
Diffstat (limited to 'packages/core/src/utils/filesearch')
| -rw-r--r-- | packages/core/src/utils/filesearch/fileSearch.ts | 2 | ||||
| -rw-r--r-- | packages/core/src/utils/filesearch/result-cache.test.ts | 7 | ||||
| -rw-r--r-- | packages/core/src/utils/filesearch/result-cache.ts | 5 |
3 files changed, 5 insertions, 9 deletions
diff --git a/packages/core/src/utils/filesearch/fileSearch.ts b/packages/core/src/utils/filesearch/fileSearch.ts index 480d5815..dff8d0ec 100644 --- a/packages/core/src/utils/filesearch/fileSearch.ts +++ b/packages/core/src/utils/filesearch/fileSearch.ts @@ -289,7 +289,7 @@ export class FileSearch { * Builds the in-memory cache for fast pattern matching. */ private buildResultCache(): void { - this.resultCache = new ResultCache(this.allFiles, this.absoluteDir); + this.resultCache = new ResultCache(this.allFiles); // The v1 algorithm is much faster since it only looks at the first // occurence of the pattern. We use it for search spaces that have >20k // files, because the v2 algorithm is just too slow in those cases. diff --git a/packages/core/src/utils/filesearch/result-cache.test.ts b/packages/core/src/utils/filesearch/result-cache.test.ts index 0b1b4e17..fcfa3f00 100644 --- a/packages/core/src/utils/filesearch/result-cache.test.ts +++ b/packages/core/src/utils/filesearch/result-cache.test.ts @@ -4,7 +4,6 @@ * SPDX-License-Identifier: Apache-2.0 */ -import path from 'node:path'; import { test, expect } from 'vitest'; import { ResultCache } from './result-cache.js'; @@ -17,7 +16,7 @@ test('ResultCache basic usage', async () => { 'subdir/other.js', 'subdir/nested/file.md', ]; - const cache = new ResultCache(files, path.resolve('.')); + const cache = new ResultCache(files); const { files: resultFiles, isExactMatch } = await cache.get('*.js'); expect(resultFiles).toEqual(files); expect(isExactMatch).toBe(false); @@ -25,7 +24,7 @@ test('ResultCache basic usage', async () => { test('ResultCache cache hit/miss', async () => { const files = ['foo.txt', 'bar.js', 'baz.md']; - const cache = new ResultCache(files, path.resolve('.')); + const cache = new ResultCache(files); // First call: miss const { files: result1Files, isExactMatch: isExactMatch1 } = await cache.get('*.js'); @@ -44,7 +43,7 @@ test('ResultCache cache hit/miss', async () => { test('ResultCache best base query', async () => { const files = ['foo.txt', 'foobar.js', 'baz.md']; - const cache = new ResultCache(files, path.resolve('.')); + const cache = new ResultCache(files); // Cache a broader query cache.set('foo', ['foo.txt', 'foobar.js']); diff --git a/packages/core/src/utils/filesearch/result-cache.ts b/packages/core/src/utils/filesearch/result-cache.ts index 77b99aec..cf0c2b4b 100644 --- a/packages/core/src/utils/filesearch/result-cache.ts +++ b/packages/core/src/utils/filesearch/result-cache.ts @@ -13,10 +13,7 @@ export class ResultCache { private hits = 0; private misses = 0; - constructor( - private readonly allFiles: string[], - private readonly absoluteDir: string, - ) { + constructor(private readonly allFiles: string[]) { this.cache = new Map(); } |
