Explorar el Código

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

zhufengzhufeng hace 5 años
padre
commit
9cd988342c
Se han modificado 1 ficheros con 1 adiciones y 1 borrados
  1. 1 1
      packages/reactivity/src/collectionHandlers.ts

+ 1 - 1
packages/reactivity/src/collectionHandlers.ts

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