From e4b6857d28555a5afe4d6a61e2c515a924c62a61 Mon Sep 17 00:00:00 2001 From: jazelly Date: Wed, 9 Apr 2025 16:16:35 +0930 Subject: [PATCH] chore: early return traversal when unnecessary render found --- packages/scan/src/core/instrumentation.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/scan/src/core/instrumentation.ts b/packages/scan/src/core/instrumentation.ts index 94315e3d..7af132b3 100644 --- a/packages/scan/src/core/instrumentation.ts +++ b/packages/scan/src/core/instrumentation.ts @@ -368,13 +368,13 @@ function isRenderUnnecessaryTraversal( _propsName: string, prevValue: unknown, nextValue: unknown, -): void { - if ( - !isEqual(prevValue, nextValue) && - !isValueUnstable(prevValue, nextValue) - ) { - this.isRequiredChange = true; - } +): boolean { + const isRquiredChange = + !isEqual(prevValue, nextValue) && !isValueUnstable(prevValue, nextValue); + this.isRequiredChange = isRquiredChange; + // no need to continue traversal if found a prop change necessary + // returning true to tell bippy to stop traversing the props list + return isRquiredChange; } // FIXME: calculation is slow