perf(reactivity): avoid triggering Map.has twice on non-reactive keys (#1972)

This commit is contained in:
Pick
2020-08-26 23:41:18 +08:00
committed by GitHub
parent d5c4f6ed4d
commit 97bc30edad
2 changed files with 14 additions and 1 deletions

View File

@@ -59,7 +59,9 @@ function has(this: CollectionTypes, key: unknown, isReadonly = false): boolean {
!isReadonly && track(rawTarget, TrackOpTypes.HAS, key)
}
!isReadonly && track(rawTarget, TrackOpTypes.HAS, rawKey)
return target.has(key) || target.has(rawKey)
return key === rawKey
? target.has(key)
: target.has(key) || target.has(rawKey)
}
function size(target: IterableCollections, isReadonly = false) {