perf(reactivity): only call Set.add if doesn't already have value (#3307)

This commit is contained in:
zhufengzhufeng 2021-02-26 03:57:35 +08:00 committed by GitHub
parent 5ad4036e29
commit 9cd988342c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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