Skip to content

Commit 9cd9883

Browse files
perf(reactivity): only call Set.add if doesn't already have value (#3307)
1 parent 5ad4036 commit 9cd9883

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

packages/reactivity/src/collectionHandlers.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ function add(this: SetTypes, value: unknown) {
7676
const target = toRaw(this)
7777
const proto = getProto(target)
7878
const hadKey = proto.has.call(target, value)
79-
target.add(value)
8079
if (!hadKey) {
80+
target.add(value)
8181
trigger(target, TriggerOpTypes.ADD, value, value)
8282
}
8383
return this

0 commit comments

Comments
 (0)