Re:Partial loop unrolling in JavaScript
by btilly on Tuesday July 13, 2010 @06:54PM
(#1513016)
http://fatagnus.com/unrolling-your-loop-for-better-performan... has a better variation on the technique. In any case I would not bother with any of this without careful profiling in different browsers. In particular a lot of them have JIT, and I would expect JIT to automatically optimize some of this stuff. (Either now or in the future.)
Re:Partial loop unrolling in JavaScript
by weeksie on Tuesday July 13, 2010 @08:45PM
(#1513213)
If you're really having performance problems that will be fixed like that then why not use Duff's Device? It's (and this is sure sayin' something) easier to read than that.
Re:Partial loop unrolling in JavaScript
by saurik on Wednesday July 14, 2010 @03:23AM
(#1513926)
Because Duff's device involves a switch outside a while with cases inside, syntax that is not allowed by JavaScript (which carefully defines a switch to consist of case clauses, each of which posessing a statement list). That said, you could still do something at least reasomably similar inside of the while (with an offset that you reset in the loop increment expression).