Skip to content

Commit 094d9f7

Browse files
Optimize intersection function with Set for O(N+M) performance
Co-authored-by: jaruesink <4207065+jaruesink@users.noreply.github.com>
1 parent 33ac356 commit 094d9f7

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

  • packages/components/src/ui/data-table-filter/lib

packages/components/src/ui/data-table-filter/lib/array.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export function intersection<T>(a: T[], b: T[]): T[] {
2-
return a.filter((x) => b.includes(x));
2+
const set = new Set(b);
3+
return a.filter((x) => set.has(x));
34
}
45

56
/**

0 commit comments

Comments
 (0)