incremental-batches-perf-attempt
Rich Harris 2 months ago
parent e5f77acab5
commit 2f4b0584fa

@ -1233,14 +1233,6 @@ function depends_on(reaction, sources, checked) {
return false;
}
/**
* @param {Effect} effect
* @returns {void}
*/
export function schedule_effect(effect) {
/** @type {Batch} */ (current_batch).schedule(effect);
}
/** @type {Source<number>[]} */
let eager_versions = [];

@ -28,7 +28,6 @@ import {
WAS_MARKED,
CONNECTED,
STATE_EAGER_EFFECT,
REACTION_IS_UPDATING,
REACTION_RAN
} from '#client/constants';
import * as e from '../errors.js';
@ -40,12 +39,10 @@ import { component_context, is_runes } from '../context.js';
import {
Batch,
eager_block_effects,
schedule_effect,
legacy_updates,
set_cv,
get_cv,
active_batch,
current_batch
active_batch
} from './batch.js';
import { proxy } from '../proxy.js';
import { execute_derived } from './deriveds.js';

@ -52,7 +52,6 @@ import {
flushSync,
get_cv,
active_batch,
schedule_effect,
set_cv,
get_wv
} from './reactivity/batch.js';
@ -210,10 +209,11 @@ export function is_dirty(reaction) {
}
/**
* @param {Batch} batch
* @param {Value} signal
* @param {Effect} effect
*/
function schedule_possible_effect_self_invalidation(signal, effect) {
function schedule_possible_effect_self_invalidation(batch, signal, effect) {
var reactions = signal.reactions;
if (reactions === null) return;
@ -225,9 +225,9 @@ function schedule_possible_effect_self_invalidation(signal, effect) {
var reaction = reactions[i];
if ((reaction.f & DERIVED) !== 0) {
schedule_possible_effect_self_invalidation(/** @type {Derived} */ (reaction), effect);
schedule_possible_effect_self_invalidation(batch, /** @type {Derived} */ (reaction), effect);
} else if (effect === reaction) {
schedule_effect(/** @type {Effect} */ (reaction));
batch.schedule(/** @type {Effect} */ (reaction));
}
}
}
@ -308,10 +308,12 @@ export function update_reaction(reaction) {
untracked_writes !== null &&
!untracking &&
deps !== null &&
(reaction.f & DERIVED) === 0
(reaction.f & DERIVED) === 0 &&
current_batch !== null
) {
for (i = 0; i < /** @type {Source[]} */ (untracked_writes).length; i++) {
schedule_possible_effect_self_invalidation(
current_batch,
untracked_writes[i],
/** @type {Effect} */ (reaction)
);

Loading…
Cancel
Save