Refactor cmdsForPath() to be nicer to the GC

On the particular large path I was testing, the time to run a single
cmdsForPath() went from more than 15 seconds down to 2.4 seconds. This
path contained many, many cubic curve commands.
Merge pull request #493 from LLK/optimize-svg-import

Refactor cmdsForPath() to be nicer to the GC