> > > A couple of things: > 1) Isn't there a danger of the async call in next() throwing an > infinite loop if things are running slow? >
Good catch, Angus! I'm open for suggestions on ways to fix this cleanly without mucking up the current logic too much... Just having a boolean flag for this special case seems kind of ugly, but perhaps that is the right thing to do. > 2) I'm wondering if there's any way to avoid copying the items at the > beginning of each reduce() call - might be an impact for larger > collections - perhaps you don't need to use shift to iterate? > > Its a valid concern, but I'm not sure that it is a real problem. Copying is O(n) and so is reduce, so the big O running time isn't really affected. Plus the copying is implemented by a native function. Lets look at some hard numbers :) http://jsperf.com/cost-of-copying Chrome doesn't seem to do too bad, and if Firefox and Safari performed as well, I would say that it is not worth it to change the code. However, it is an order of magnitude less performant on FF and Safari (don't even want to imagine IE, now) so I think you were correct, and I will have to do something about this. Thanks for taking your time to look through my code and give me feedback, Angus! _Nick_ -- To view archived discussions from the original JSMentors Mailman list: http://www.mail-archive.com/[email protected]/ To search via a non-Google archive, visit here: http://www.mail-archive.com/[email protected]/ To unsubscribe from this group, send email to [email protected]
