Skip to content

Commit 5c0c8c8

Browse files
gebilaoxiongyyx990803
authored andcommitted
improve: optimize the performance of scheduler (vuejs#5607)
1 parent a8da4fb commit 5c0c8c8

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/core/observer/scheduler.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ let index = 0
2424
* Reset the scheduler's state.
2525
*/
2626
function resetSchedulerState () {
27-
queue.length = activatedChildren.length = 0
27+
index = queue.length = activatedChildren.length = 0
2828
has = {}
2929
if (process.env.NODE_ENV !== 'production') {
3030
circular = {}
@@ -134,10 +134,10 @@ export function queueWatcher (watcher: Watcher) {
134134
// if already flushing, splice the watcher based on its id
135135
// if already past its id, it will be run next immediately.
136136
let i = queue.length - 1
137-
while (i >= 0 && queue[i].id > watcher.id) {
137+
while (i > index && queue[i].id > watcher.id) {
138138
i--
139139
}
140-
queue.splice(Math.max(i, index) + 1, 0, watcher)
140+
queue.splice(i + 1, 0, watcher)
141141
}
142142
// queue the flush
143143
if (!waiting) {

0 commit comments

Comments
 (0)