Skip to content

Commit

Permalink
perf(reactivity): only call Set.add if doesn't already have value (#3307
Browse files Browse the repository at this point in the history
)
  • Loading branch information
zhufengzhufeng committed Feb 25, 2021
1 parent 5ad4036 commit 9cd9883
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/reactivity/src/collectionHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ function add(this: SetTypes, value: unknown) {
const target = toRaw(this)
const proto = getProto(target)
const hadKey = proto.has.call(target, value)
target.add(value)
if (!hadKey) {
target.add(value)
trigger(target, TriggerOpTypes.ADD, value, value)
}
return this
Expand Down

0 comments on commit 9cd9883

Please sign in to comment.