reduce indentation

pull/10798/head
Rich Harris 2 years ago
parent 8641aeb619
commit 98cffcf0b0

@ -358,43 +358,44 @@ function reconcile_tracked_array(array, each_block, dom, is_controlled, render_f
var a = a_blocks.length; var a = a_blocks.length;
var b = array.length; var b = array.length;
/** @type {Array<import('#client').EachItemBlock>} */ // fast path  array is empty
var b_blocks;
var block;
if (b === 0) { if (b === 0) {
// Remove old blocks // Remove old blocks
if (is_controlled && a !== 0) { if (is_controlled && a !== 0) {
clear_text_content(dom); clear_text_content(dom);
} }
while (a > 0) { while (a > 0) {
block = a_blocks[--a]; destroy_each_item_block(a_blocks[--a], is_controlled);
destroy_each_item_block(block, is_controlled);
} }
b_blocks = []; each_block.v = [];
} else { return;
var a_end = a - 1; }
var b_end = b - 1;
var key;
var item;
var i;
b_blocks = Array(b); /** @type {Array<import('#client').EachItemBlock>} */
var b_blocks = Array(b);
// fast path — array WAS empty
if (a === 0) { if (a === 0) {
// Create new blocks // Create new blocks
while (b > 0) { for (var i = 0; i < b; i += 1) {
i = b_end - --b; var block = each_item_block(array[i], keys[i], i, render_fn, flags);
block = each_item_block(array[i], keys[i], i, render_fn, flags);
b_blocks[i] = block; b_blocks[i] = block;
insert_each_item_block(block, dom, is_controlled, null); insert_each_item_block(block, dom, is_controlled, null);
} }
} else {
each_block.v = b_blocks;
return;
}
var a_end = a - 1;
var b_end = b - 1;
var key;
var item;
var is_animated = (flags & EACH_IS_ANIMATED) !== 0; var is_animated = (flags & EACH_IS_ANIMATED) !== 0;
var should_update_block = var should_update_block =
(flags & (EACH_ITEM_REACTIVE | EACH_INDEX_REACTIVE)) !== 0 || is_animated; is_animated || (flags & (EACH_ITEM_REACTIVE | EACH_INDEX_REACTIVE)) !== 0;
var start = 0; var start = 0;
/** @type {null | Text | Element | Comment} */ /** @type {null | Text | Element | Comment} */
@ -526,8 +527,6 @@ function reconcile_tracked_array(array, each_block, dom, is_controlled, render_f
last_block = block; last_block = block;
} }
} }
}
}
each_block.v = b_blocks; each_block.v = b_blocks;
} }

Loading…
Cancel
Save