chore: bit of code cleanup (#10218)

pull/10225/head
Simon H 7 months ago committed by GitHub
parent 2e238ada92
commit 61118835db
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -379,13 +379,15 @@ function execute_signal_fn(signal) {
// If we have more than 16 elements in the array then use a Set for faster performance
// TODO: evaluate if we should always just use a Set or not here?
const full_current_dependencies_set =
current_dep_length > 16 ? new Set(full_current_dependencies) : null;
current_dep_length > 16 && deps_length - current_dependencies_index > 1
? new Set(full_current_dependencies)
: null;
for (i = current_dependencies_index; i < deps_length; i++) {
const dependency = dependencies[i];
if (
(full_current_dependencies_set !== null &&
!full_current_dependencies_set.has(dependency)) ||
!full_current_dependencies.includes(dependency)
full_current_dependencies_set !== null
? !full_current_dependencies_set.has(dependency)
: !full_current_dependencies.includes(dependency)
) {
remove_consumer(signal, dependency);
}
@ -1084,7 +1086,7 @@ function mark_subtree_children_inert(signal, inert, visited_blocks) {
for (i = 0; i < references.length; i++) {
const reference = references[i];
if ((reference.f & IS_EFFECT) !== 0) {
mark_subtree_inert(references[i], inert, visited_blocks);
mark_subtree_inert(reference, inert, visited_blocks);
}
}
}

@ -199,6 +199,7 @@ describe('signals', () => {
};
});
// outside of test function so that they are unowned signals
let count = $.source(0);
let calc = $.derived(() => {
if ($.get(count) >= 2) {
@ -207,7 +208,7 @@ describe('signals', () => {
return $.get(count) * 2;
});
test('effect with derived using new derived every time', () => {
test('effect with derived using unowned derived every time', () => {
const log: Array<number | string> = [];
const effect = $.user_effect(() => {

Loading…
Cancel
Save