File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
packages/svelte/src/internal/client Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -350,9 +350,16 @@ function execute_signal_fn(signal) {
350
350
if ( current_dependencies !== null ) {
351
351
let i ;
352
352
if ( dependencies !== null ) {
353
- for ( i = current_dependencies_index ; i < dependencies . length ; i ++ ) {
353
+ const dep_length = dependencies . length ;
354
+ // If we have more than 16 elements in the array then use a Set for faster performance
355
+ // TODO: evaluate if we should always just use a Set or not here?
356
+ const current_dependencies_set = dep_length > 16 ? new Set ( current_dependencies ) : null ;
357
+ for ( i = current_dependencies_index ; i < dep_length ; i ++ ) {
354
358
const dependency = dependencies [ i ] ;
355
- if ( ! current_dependencies . includes ( dependency ) ) {
359
+ if (
360
+ ( current_dependencies_set !== null && ! current_dependencies_set . has ( dependency ) ) ||
361
+ ! current_dependencies . includes ( dependency )
362
+ ) {
356
363
remove_consumer ( signal , dependency , false ) ;
357
364
}
358
365
}
You can’t perform that action at this time.
0 commit comments