refactor: merge measure + capture_size into one read loop

Both are pure DOM reads, so there's no batching reason to keep them
in separate loops over the destroyed items.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
pull/18267/head
Mathias Picker 3 days ago
parent 145a5cc204
commit 2e9d69a791

@ -628,9 +628,13 @@ function reconcile(state, array, anchor, flags, get_key) {
var controlled_anchor = (flags & EACH_IS_CONTROLLED) !== 0 && length === 0 ? anchor : null;
if (is_animated) {
// Doing all the reads _then_ all the writes minimises layout flushes
for (i = 0; i < destroy_length; i += 1) to_destroy[i].nodes?.a?.measure();
for (i = 0; i < destroy_length; i += 1) to_destroy[i].nodes?.a?.capture_size();
// Doing all the reads _then_ all the writes minimises layout flushes.
// `measure` and `capture_size` are both reads, so they share a loop.
for (i = 0; i < destroy_length; i += 1) {
var am = to_destroy[i].nodes?.a;
am?.measure();
am?.capture_size();
}
for (i = 0; i < destroy_length; i += 1) to_destroy[i].nodes?.a?.set_position();
for (i = 0; i < destroy_length; i += 1) to_destroy[i].nodes?.a?.set_transform();
}

Loading…
Cancel
Save