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.