craftyjs/Crafty — pull request #424 by starwed (2013-02-24 19:34:51+00:00)
Title: Reduce Garbage: Refactor Canvas.draw to avoid creation of transient objects

The current draw implementation creates a lot of garbage: it produces a few temporary objects per frame for every entity drawn. This patch creates a more permanent object that gets reused, avoiding the garbage creation problem.

It still creates a few temporary variables, since local variables are slightly faster to access than object properties, and I was trying to be conservative. Temporary variables aren't nearly as big a problem as objects, but it might be worth checking whether there's actually a speed difference.