Hi Karl,
The biggest issue I see there is what look like global variables:
Without 'var' statements in your closure, you're using implicitly-
declared global variables, which is a very bad idea. I haven't had
time to blog the last few months, but I have a post on this:
http://blog.niftysnippets.org/2008/03/horror-of-implicit-globals.html
On the code, no *massive* inefficiencies jump out, but I would
probably do something like this if the list is long:
list.row.each(function(row)
{
var x, len;
for (len = aNames.length, x = 0; x < len; x++)
{
if (row.Name.toLowerCase().indexOf(aNames[x]) >= 0)
{
filterlist.row[filterlist.row.length] = row;
break;
}
}
});
I'm assuming 'filterlist' is in-scope for the closure; a global or a
local var in the enclosing function, that sort of thing.
Prototype's Enumerable module (which is mixed into Array) has a
collect method that is for this sort of thing, but I doubt it would be
more efficient than the above:
http://www.prototypejs.org/api/enumerable/collect
If you're seeing things being really slow, I suspect the problem may
be outside of the code you quoted.
HTH,
--
T.J. Crowder
tj / crowder software / com