LeaVerou/prism — pull request #47 by jacobrask (2012-10-27 13:04:13+00:00)
Title: Grammar format optimizations

I have a program which does highlighting in real time, so speed is really important. I compared different highlighters, and Prism were among the fastest (and smallest), so great work! However, I was able to do some more optimization by changing the grammar format a bit to use arrays instead of objects. You can see comparison benchmarks at [jsperf](http://jsperf.com/prismjs/5).

The speed improvements are quite significant in some browsers, even for the small chunks of code I have tested, but I understand if you reject this patch because you prefer the current format and need backward compatibility with existing grammars.

I also think that the current format relying on the order of objects is a bit risky. Previously all browsers did respect the insertion order, but Chrome, Opera and recent versions of IE now put properties with integer keys first. There's no guarantee that future implementations will respect the order of objects.