Very minor speedup to Array#filter. #855

wants to merge 2 commits into


None yet
3 participants

dcporter commented Oct 23, 2012

Some testing by @mauritslamers indicates that this optimized code delivers a human-noticeable speedup to Array#filter when run on ridiculously large arrays.


mauritslamers commented on 50d7f7a Oct 3, 2012

After reading this, and comparing with my test data, it turns out my test data turns out not to have any undefined items, so I don't expect much difference.

As you write: the more tests we do outside the loop the better. Therefore every test that is done inside the loop needs to be reviewed. For example: how often does it occur that we have arrays with mixed standard objects and SC objects? A test is done against .get for every iteration of the loop, while I think it is unlikely that an array will have a mix of SC objects and hashes.

The same goes for SC.isEqual, which perhaps should only be called on SC objects, not on hashes.


dcporter replied Oct 3, 2012


mauritslamers replied Oct 3, 2012

this should probably be idx, not index :)


dcporter replied Oct 3, 2012

Indeed. Fixed in latest. Like I said, I had to run to work and didn't have time to run it properly, or even unit test, and jslint has so many problems with that file that it was no help at all... =)


publickeating commented Dec 6, 2012

Rebased onto master. Thanks!

@dcporter dcporter deleted the team/dcporter/array-filter branch Mar 13, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment