Skip to content

Commit ebeaf80

Browse files
author
Steven Orvell
committed
Avoid forEach
1 parent 8cad475 commit ebeaf80

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

src/micro/behaviors.html

+6-6
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,9 @@
133133
},
134134

135135
_doBehavior: function(name, args) {
136-
this.behaviors.forEach(function(b) {
137-
this._invokeBehavior(b, name, args);
138-
}, this);
136+
for (var i=0; i < this.behaviors.length; i++) {
137+
this._invokeBehavior(this.behaviors[i], name, args);
138+
}
139139
this._invokeBehavior(this, name, args);
140140
},
141141

@@ -147,9 +147,9 @@
147147
},
148148

149149
_marshalBehaviors: function() {
150-
this.behaviors.forEach(function(b) {
151-
this._marshalBehavior(b);
152-
}, this);
150+
for (var i=0; i < this.behaviors.length; i++) {
151+
this._marshalBehavior(this.behaviors[i]);
152+
}
153153
this._marshalBehavior(this);
154154
}
155155

src/standard/annotations.html

+12-10
Original file line numberDiff line numberDiff line change
@@ -279,32 +279,34 @@
279279
// construct `$` map (from id annotations)
280280
_marshalIdNodes: function() {
281281
this.$ = {};
282-
this._notes.forEach(function(a) {
282+
for (var i=0, l=this._notes.length, a; (i<l) && (a=this._notes[i]); i++) {
283283
if (a.id) {
284284
this.$[a.id] = this._findAnnotatedNode(this.root, a);
285285
}
286-
}, this);
286+
}
287287
},
288288

289289
// concretize `_nodes` map (from anonymous annotations)
290290
_marshalAnnotatedNodes: function() {
291-
if (this._nodes) {
292-
this._nodes = this._nodes.map(function(a) {
293-
return this._findAnnotatedNode(this.root, a);
294-
}, this);
291+
if (this._nodes && this._nodes.length) {
292+
var r = new Array(this._nodes.length);
293+
for (var i=0; i < this._nodes.length; i++) {
294+
r[i] = this._findAnnotatedNode(this.root, this._nodes[i]);
295+
}
296+
this._nodes = r;
295297
}
296298
},
297299

298300
// install event listeners (from event annotations)
299301
_marshalAnnotatedListeners: function() {
300-
this._notes.forEach(function(a) {
302+
for (var i=0, l=this._nodes.length, a; (i<l) && (a=this._nodes[i]); i++) {
301303
if (a.events && a.events.length) {
302304
var node = this._findAnnotatedNode(this.root, a);
303-
a.events.forEach(function(e) {
305+
for (var j=0, e$=a.events, e; (j<e$.length) && (e=e$[j]); j++) {
304306
this.listen(node, e.name, e.value);
305-
}, this);
307+
}
306308
}
307-
}, this);
309+
}
308310
}
309311

310312
});

0 commit comments

Comments
 (0)