This project has moved and is read-only. For the latest updates, please go here.

Select calls clause function twice

May 10, 2009 at 5:10 PM

Out of curiosity, in the Select method, why not call the clause function once, then if the result evaluates to true, add it to the array? This would roughly double performance of select.

So, from:

for (var i = 0; i < this.items.length; i++) {
  if (clause(this.items[i])) {
     newArray[newArray.length] = clause(this.items[i]);


To this:

for (var i = 0; i < this.items.length; i++) {

  var result = clause(this.items[i]);
  if (result)
     newArray[newArray.length] = result;


-- Curtis


Jun 17, 2009 at 12:06 AM

Thanks. This has been fixed.