Skip to content

Commit d6fa5c7

Browse files
authored
cleanup signals code a bit (#10346)
1 parent dc8ca46 commit d6fa5c7

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

packages/svelte/src/internal/client/runtime.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -327,22 +327,23 @@ function is_signal_dirty(signal) {
327327
*/
328328
function execute_signal_fn(signal) {
329329
const init = signal.i;
330+
const flags = signal.f;
330331
const previous_dependencies = current_dependencies;
331332
const previous_dependencies_index = current_dependencies_index;
332333
const previous_untracked_writes = current_untracked_writes;
333334
const previous_consumer = current_consumer;
334335
const previous_block = current_block;
335336
const previous_component_context = current_component_context;
336337
const previous_skip_consumer = current_skip_consumer;
337-
const is_render_effect = (signal.f & RENDER_EFFECT) !== 0;
338+
const is_render_effect = (flags & RENDER_EFFECT) !== 0;
338339
const previous_untracking = current_untracking;
339340
current_dependencies = /** @type {null | import('./types.js').Signal[]} */ (null);
340341
current_dependencies_index = 0;
341342
current_untracked_writes = null;
342343
current_consumer = signal;
343344
current_block = signal.b;
344345
current_component_context = signal.x;
345-
current_skip_consumer = !is_flushing_effect && (signal.f & UNOWNED) !== 0;
346+
current_skip_consumer = !is_flushing_effect && (flags & UNOWNED) !== 0;
346347
current_untracking = false;
347348

348349
// Render effects are invoked when the UI is about to be updated - run beforeUpdate at that point
@@ -412,6 +413,10 @@ function execute_signal_fn(signal) {
412413
if (consumers === null) {
413414
dependency.c = [signal];
414415
} else if (consumers[consumers.length - 1] !== signal) {
416+
// TODO: should this be:
417+
//
418+
// } else if (!consumers.includes(signal)) {
419+
//
415420
consumers.push(signal);
416421
}
417422
}
@@ -970,7 +975,7 @@ export function get(signal) {
970975
) {
971976
if (current_dependencies === null) {
972977
current_dependencies = [signal];
973-
} else if (signal !== current_dependencies[current_dependencies.length - 1]) {
978+
} else {
974979
current_dependencies.push(signal);
975980
}
976981
}

0 commit comments

Comments
 (0)