mozilla/pdf.js — pull request #959 by jviereck (2011-12-18 21:59:47+00:00)
Title: Cache Cmd object to reduce number of created objects

Every `Cmd` in PDF.JS is a object with a `cmd` string property. The number of different `cmd` strings used is somewhat in the region around 50 if rendering the first few pages of the `pdf.pdf` document. However, for each command, a new `Cmd` object is created, although the `Cmd` object with the same `cmd` value can get reused. E.g. in the case of the `pdf.pdf` document, if we render the first page, already 334.140 (!!!) `Cmd` objects are created.

This patch makes sure we create each `Cmd` object only once and reuse them.