Skip to content

Commit 0b34253

Browse files
committed
address duplicate filtering and Combine predicates to reduce traversal
1 parent 8031ae1 commit 0b34253

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/core/ignore/GitIgnoreController.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ export class GitIgnoreController extends BaseIgnoreController {
6363
await this.findGitignoreFilesRecursively(this.cwd)
6464

6565
// Load any files discovered by recursion that weren't loaded yet
66+
// De-duplicate discovered paths to avoid redundant loads
67+
this.gitignoreFiles = Array.from(new Set(this.gitignoreFiles))
6668
for (const p of this.gitignoreFiles) {
6769
if (!this.gitignoreContents.has(p)) {
6870
await this.loadGitignoreFile(p)

src/services/ripgrep/index.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,12 @@ export async function regexSearchFiles(
215215
// console.log(results)
216216

217217
// Filter results using both controllers if provided
218-
const filteredResults = results
219-
.filter((result) => gitIgnoreController?.validateAccess(result.file) ?? true)
220-
.filter((result) => rooIgnoreController?.validateAccess(result.file) ?? true)
218+
const filteredResults = results.filter((result) => {
219+
const file = result.file
220+
return (
221+
(gitIgnoreController?.validateAccess(file) ?? true) && (rooIgnoreController?.validateAccess(file) ?? true)
222+
)
223+
})
221224

222225
return formatResults(filteredResults, cwd)
223226
}

0 commit comments

Comments
 (0)