Skip to content

Commit

Permalink
Timerify isMatch
Browse files Browse the repository at this point in the history
  • Loading branch information
webpro committed Apr 11, 2024
1 parent 66ed008 commit 5d51620
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/knip/src/IssueCollector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import micromatch from 'micromatch';
import { initCounters, initIssues } from './issues/initializers.js';
import type { ConfigurationHint, Issue, Rules } from './types/issues.js';
import { relative } from './util/path.js';
import { timerify } from './util/Performance.js';

type Filters = Partial<{
dir: string;
Expand All @@ -18,6 +19,8 @@ const hasHint = (hints: Set<ConfigurationHint>, hint: ConfigurationHint) =>
item => item.identifier === hint.identifier && item.type === hint.type && item.workspaceName === hint.workspaceName
);

const isMatch = timerify(micromatch.isMatch, 'isMatch');

/**
* - Collects issues and counts them
* - Hands them out, to be consumed by reporters
Expand All @@ -43,7 +46,7 @@ export class IssueCollector {
addIgnorePatterns(patterns: string[]) {
for (const pattern of patterns) this.ignorePatterns.add(pattern);
const p = [...this.ignorePatterns];
this.isMatch = (filePath: string) => micromatch.isMatch(filePath, p, { dot: true });
this.isMatch = (filePath: string) => isMatch(filePath, p, { dot: true });
}

addFileCounts({ processed, unused }: { processed: number; unused: number }) {
Expand Down

0 comments on commit 5d51620

Please sign in to comment.