Minimize memory usage of font-related arrays.

This patch replaces some vanilla arrays with typed arrays, and avoids
some array copying.

It reduces the peak RSS when viewing
http://www.dynacw.co.jp/Portals/3/fontsamplepdf/sample_4942546800828.pdf
from ~940 MiB to ~750 MiB, and reduces its load time from 83 to 76 ms.
This commit is contained in:
Nicholas Nethercote 2014-07-21 22:19:31 -07:00
parent 584fef90ab
commit c7f02d2c8e
2 changed files with 35 additions and 13 deletions

View file

@ -436,7 +436,7 @@ function bytesToString(bytes) {
function stringToArray(str) {
var length = str.length;
var array = [];
var array = new Uint16Array(length);
for (var i = 0; i < length; ++i) {
array[i] = str.charCodeAt(i);
}