Avoid using shift in flush

We noticed that there was a large amount of memory being created as part of the flush method, which seems to be due to some array optimizations in old JS engines. This seems to be easily fixed by changing to a simple for loop instead of a while loop that modifies the array during iteration. This is the same pattern that is used for the `render_callbacks`.
pull/4356/head
Jordan Gensler 6 years ago committed by GitHub
parent 3cbe38cbf1
commit 45053c26e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -37,12 +37,14 @@ export function flush() {
do {
// first, call beforeUpdate functions
// and update components
while (dirty_components.length) {
const component = dirty_components.shift();
for (let i = 0; i < dirty_components.length; i += 1) {
const component = dirty_components[i];
set_current_component(component);
update(component.$$);
}
dirty_components.length = 0;
while (binding_callbacks.length) binding_callbacks.pop()();
// then, once components are updated, call

Loading…
Cancel
Save