File tree 2 files changed +9
-2
lines changed
2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change 4
4
5
5
* Fix binding to module-level variables ([ #4086 ] ( https://github.com/sveltejs/svelte/issues/4086 ) )
6
6
* Disallow attribute/prop names from matching two-way-bound names or ` {shorthand} ` attribute/prop names ([ #4325 ] ( https://github.com/sveltejs/svelte/issues/4325 ) )
7
+ * Improve performance of ` flush() ` by not using ` .shift() ` ([ #4356 ] ( https://github.com/sveltejs/svelte/pull/4356 ) )
7
8
* Fix code generation error with precedence of arrow functions ([ #4384 ] ( https://github.com/sveltejs/svelte/issues/4384 ) )
8
9
9
10
## 3.18.1
Original file line number Diff line number Diff line change @@ -31,18 +31,23 @@ export function add_flush_callback(fn) {
31
31
flush_callbacks . push ( fn ) ;
32
32
}
33
33
34
+ let flushing = false ;
34
35
const seen_callbacks = new Set ( ) ;
35
36
export function flush ( ) {
37
+ if ( flushing ) return ;
38
+ flushing = true ;
36
39
37
40
do {
38
41
// first, call beforeUpdate functions
39
42
// and update components
40
- while ( dirty_components . length ) {
41
- const component = dirty_components . shift ( ) ;
43
+ for ( let i = 0 ; i < dirty_components . length ; i += 1 ) {
44
+ const component = dirty_components [ i ] ;
42
45
set_current_component ( component ) ;
43
46
update ( component . $$ ) ;
44
47
}
45
48
49
+ dirty_components . length = 0 ;
50
+
46
51
while ( binding_callbacks . length ) binding_callbacks . pop ( ) ( ) ;
47
52
48
53
// then, once components are updated, call
@@ -67,6 +72,7 @@ export function flush() {
67
72
}
68
73
69
74
update_scheduled = false ;
75
+ flushing = false ;
70
76
seen_callbacks . clear ( ) ;
71
77
}
72
78
You can’t perform that action at this time.
0 commit comments