Object._each() optimization
Reported by Marton Kiss-Albert | July 30th, 2008 @ 10:10 PM | in 1.6.1
// OLD VERSION:
_each: function(iterator) {
for (var i = 0, length = this.length; i < length; i++)
iterator(this[i]);
},
// NEW VERSION:
_each: function(iterator) {
for (var i = 0, length = this.length; i < length; iterator(this[i++]));
},
Comments and changes to this ticket
-
John-David Dalton July 31st, 2008 @ 12:06 AM
what about:
_each: function(iterator) { for (var i = 0, item; item = this[i] ; i++) iterator(item); },OR
_each: function(iterator) { for (var i = 0, item; item = this[i++];) iterator(item); },Can you provide simple benchmarks for each of these so we may compare the performance.
-
John-David Dalton July 31st, 2008 @ 12:09 AM
OR even
_each: function(iterator) { for (var i = 0, item; item = this[i++]; iterator(item)); }, -
John-David Dalton July 31st, 2008 @ 12:10 AM
- → Tag changed from needs_benchmarks optimization to needs_benchmarks needs_patch needs_tests optimization
- → Milestone changed from to 1.6.1
- → State changed from new to enhancement
- → Assigned user changed from to John-David Dalton
-
Please Login or create a free account to add a new comment.
You can update this ticket by sending an email to from your email client. (help)
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
The Prototype JavaScript library.
