mozilla/pdf.js — pull request #5219 by Snuffleupagus (2014-08-20 15:28:17+00:00)
Title: Avoid creating intermediate strings in sanitizeMetrics

This patch avoids creating many intermediate strings, by instead using an array and then joining the elements, when writing dummy width/lsb entries for glyphs where those are missing.
For the relevant PDF files in our test suite (see https://gist.github.com/Snuffleupagus/27f6586ceac79dadacbe), the average number of intermediate strings are well over 1000.
Since we know the length of the array beforehand, we can also avoid resizings by allocating the right number of elements when the array is created.