Skip to content

Commit

Permalink
Avoid forEach
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven Orvell committed Oct 19, 2015
1 parent 8cad475 commit ebeaf80
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
12 changes: 6 additions & 6 deletions src/micro/behaviors.html
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@
},

_doBehavior: function(name, args) {
this.behaviors.forEach(function(b) {
this._invokeBehavior(b, name, args);
}, this);
for (var i=0; i < this.behaviors.length; i++) {
this._invokeBehavior(this.behaviors[i], name, args);
}
this._invokeBehavior(this, name, args);
},

Expand All @@ -147,9 +147,9 @@
},

_marshalBehaviors: function() {
this.behaviors.forEach(function(b) {
this._marshalBehavior(b);
}, this);
for (var i=0; i < this.behaviors.length; i++) {
this._marshalBehavior(this.behaviors[i]);
}
this._marshalBehavior(this);
}

Expand Down
22 changes: 12 additions & 10 deletions src/standard/annotations.html
Original file line number Diff line number Diff line change
Expand Up @@ -279,32 +279,34 @@
// construct `$` map (from id annotations)
_marshalIdNodes: function() {
this.$ = {};
this._notes.forEach(function(a) {
for (var i=0, l=this._notes.length, a; (i<l) && (a=this._notes[i]); i++) {
if (a.id) {
this.$[a.id] = this._findAnnotatedNode(this.root, a);
}
}, this);
}
},

// concretize `_nodes` map (from anonymous annotations)
_marshalAnnotatedNodes: function() {
if (this._nodes) {
this._nodes = this._nodes.map(function(a) {
return this._findAnnotatedNode(this.root, a);
}, this);
if (this._nodes && this._nodes.length) {
var r = new Array(this._nodes.length);
for (var i=0; i < this._nodes.length; i++) {
r[i] = this._findAnnotatedNode(this.root, this._nodes[i]);
}
this._nodes = r;
}
},

// install event listeners (from event annotations)
_marshalAnnotatedListeners: function() {
this._notes.forEach(function(a) {
for (var i=0, l=this._nodes.length, a; (i<l) && (a=this._nodes[i]); i++) {
if (a.events && a.events.length) {
var node = this._findAnnotatedNode(this.root, a);
a.events.forEach(function(e) {
for (var j=0, e$=a.events, e; (j<e$.length) && (e=e$[j]); j++) {
this.listen(node, e.name, e.value);
}, this);
}
}
}, this);
}
}

});
Expand Down

0 comments on commit ebeaf80

Please sign in to comment.