From cc8aa5980f776397e29f9b86a990c92d259925dd Mon Sep 17 00:00:00 2001 From: Simon He <57086651+Simon-He95@users.noreply.github.com> Date: Thu, 26 Oct 2023 10:17:35 +0800 Subject: [PATCH 1/3] perf(compiler-sfc): defineOptions avoid redundant conditional judgments --- packages/reactivity/src/effect.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/reactivity/src/effect.ts b/packages/reactivity/src/effect.ts index c982dbd0b5a..97329223f42 100644 --- a/packages/reactivity/src/effect.ts +++ b/packages/reactivity/src/effect.ts @@ -396,16 +396,17 @@ export function triggerEffects( ) { // spread into array for stabilization const effects = isArray(dep) ? dep : [...dep] + const notComputedEffect: ReactiveEffect[] = [] for (const effect of effects) { if (effect.computed) { triggerEffect(effect, debuggerEventExtraInfo) + } else { + notComputedEffect.push(effect) } } - for (const effect of effects) { - if (!effect.computed) { - triggerEffect(effect, debuggerEventExtraInfo) - } - } + notComputedEffect.forEach(effect => + triggerEffect(effect, debuggerEventExtraInfo) + ) } function triggerEffect( From 8b51788d60507894e4745cd52e80499a0429bdba Mon Sep 17 00:00:00 2001 From: Simon He <57086651+Simon-He95@users.noreply.github.com> Date: Thu, 26 Oct 2023 16:35:10 +0800 Subject: [PATCH 2/3] chore: update --- packages/reactivity/src/effect.ts | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/packages/reactivity/src/effect.ts b/packages/reactivity/src/effect.ts index 97329223f42..f2e028b3aa3 100644 --- a/packages/reactivity/src/effect.ts +++ b/packages/reactivity/src/effect.ts @@ -396,17 +396,13 @@ export function triggerEffects( ) { // spread into array for stabilization const effects = isArray(dep) ? dep : [...dep] - const notComputedEffect: ReactiveEffect[] = [] - for (const effect of effects) { - if (effect.computed) { - triggerEffect(effect, debuggerEventExtraInfo) - } else { - notComputedEffect.push(effect) - } - } - notComputedEffect.forEach(effect => - triggerEffect(effect, debuggerEventExtraInfo) - ) + effects + .filter(x => { + if (!x.computed) return true + triggerEffect(x) + return false + }) + .forEach(x => triggerEffect(x)) } function triggerEffect( From 446b3d420db813741104e61ef873cca0585a12cd Mon Sep 17 00:00:00 2001 From: Simon He <57086651+Simon-He95@users.noreply.github.com> Date: Thu, 26 Oct 2023 16:36:47 +0800 Subject: [PATCH 3/3] chore: update --- packages/reactivity/src/effect.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/reactivity/src/effect.ts b/packages/reactivity/src/effect.ts index f2e028b3aa3..1fbb8d4698e 100644 --- a/packages/reactivity/src/effect.ts +++ b/packages/reactivity/src/effect.ts @@ -397,12 +397,12 @@ export function triggerEffects( // spread into array for stabilization const effects = isArray(dep) ? dep : [...dep] effects - .filter(x => { - if (!x.computed) return true - triggerEffect(x) + .filter(effect => { + if (!effect.computed) return true + triggerEffect(effect, debuggerEventExtraInfo) return false }) - .forEach(x => triggerEffect(x)) + .forEach(effect => triggerEffect(effect, debuggerEventExtraInfo)) } function triggerEffect(