Select calls clause function twice

May 10, 2009 at 4: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

 

Coordinator
Jun 16, 2009 at 11:06 PM

Thanks. This has been fixed.