]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
perf(reactivity): only call Set.add if doesn't already have value (#3307)
authorzhufengzhufeng <894918097@qq.com>
Thu, 25 Feb 2021 19:57:35 +0000 (03:57 +0800)
committerGitHub <noreply@github.com>
Thu, 25 Feb 2021 19:57:35 +0000 (14:57 -0500)
packages/reactivity/src/collectionHandlers.ts

index e43d3ac59fd23cf693f843b9ba345bcc9dc7c8c8..149bcb54d2ce9adf391c658993339846845a9e93 100644 (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