Skip to content

Commit 57c6ce1

Browse files
authored
perf: improve performance of util function "difference" in quriesObserver.ts in query-core package (#9201)
* perf: change "difference" util function * refactor: extract "new Set" function in "difference" util function
1 parent 8d41a4e commit 57c6ce1

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

packages/query-core/src/queriesObserver.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ import type {
1010
import type { QueryClient } from './queryClient'
1111

1212
function difference<T>(array1: Array<T>, array2: Array<T>): Array<T> {
13-
return array1.filter((x) => !array2.includes(x))
13+
const excludeSet = new Set(array2)
14+
return array1.filter((x) => !excludeSet.has(x))
1415
}
1516

1617
function replaceAt<T>(array: Array<T>, index: number, value: T): Array<T> {

0 commit comments

Comments
 (0)