Permalink
Browse files

Speed up Container#each for 2 times

  • Loading branch information...
ai committed Nov 7, 2015
1 parent c98bb96 commit d8ecd9ada4298cbdca350a941d3bf1a8fcd6eecc
Showing with 3 additions and 5 deletions.
  1. +3 −5 lib/container.es6
View
@@ -3,8 +3,6 @@ import warnOnce from './warn-once';
import Comment from './comment';
import Node from './node';
let lastEach = 0;
export default class Container extends Node {
push(child) {
@@ -14,10 +12,11 @@ export default class Container extends Node {
}
each(callback) {
if ( !this.lastEach ) this.lastEach = 0;
if ( !this.indexes ) this.indexes = { };
lastEach += 1;
let id = lastEach;
this.lastEach += 1;
let id = this.lastEach;
this.indexes[id] = 0;
if ( !this.nodes ) return undefined;
@@ -32,7 +31,6 @@ export default class Container extends Node {
}
delete this.indexes[id];
if ( Object.keys(this.indexes).length === 0 ) delete this.indexes;
if ( result === false ) return false;
}

1 comment on commit d8ecd9a

@vodkabears

This comment has been minimized.

Show comment
Hide comment
@vodkabears

vodkabears commented on d8ecd9a Nov 12, 2015

🔥

Please sign in to comment.