refactor: move toNumber call out of loop

This commit is contained in:
Evan You 2022-10-26 15:17:25 +08:00
parent 8e792d93a8
commit d9de6caecd
1 changed files with 2 additions and 1 deletions

View File

@ -276,8 +276,9 @@ export function trigger(
// trigger all effects for target
deps = [...depsMap.values()]
} else if (key === 'length' && isArray(target)) {
const newLength = toNumber(newValue)
depsMap.forEach((dep, key) => {
if (key === 'length' || key >= toNumber(newValue)) {
if (key === 'length' || key >= newLength) {
deps.push(dep)
}
})