improve: optimize the performance of scheduler (#5607)

This commit is contained in:
laoxiong 2017-05-07 21:41:22 +08:00 committed by Evan You
parent a8da4fb051
commit 5c0c8c8865
1 changed files with 3 additions and 3 deletions

View File

@ -24,7 +24,7 @@ let index = 0
* Reset the scheduler's state.
*/
function resetSchedulerState () {
queue.length = activatedChildren.length = 0
index = queue.length = activatedChildren.length = 0
has = {}
if (process.env.NODE_ENV !== 'production') {
circular = {}
@ -134,10 +134,10 @@ export function queueWatcher (watcher: Watcher) {
// if already flushing, splice the watcher based on its id
// if already past its id, it will be run next immediately.
let i = queue.length - 1
while (i >= 0 && queue[i].id > watcher.id) {
while (i > index && queue[i].id > watcher.id) {
i--
}
queue.splice(Math.max(i, index) + 1, 0, watcher)
queue.splice(i + 1, 0, watcher)
}
// queue the flush
if (!waiting) {