mozilla/pdf.js — pull request #4963 by CodingFabian (2014-06-17 18:50:41+00:00)
Title: reduce the amount of ctx save() and restore() when text is to scaled.

When a font is rendered which is subPixelAAEnabled it is possible for
each glyph the context is scaled and restored. This is inefficient in
two ways:
a) it is possible that the calculated scale is 1.
b) if the next glyph is scaled the same way as the last glyph, scale
does not need to change at all.

did 76344 times ctx.save(), ctx.scale(), ctx.restore(). After the patch
it only does it 5586 times.

Unfortunately I was unable to get a stable benchmark for the improvement,
but it is roughly 10%-20% faster in the showText method.

PDFs which were not using the font.remeasure will not get any difference,
a boolean check was replaced with !==.