mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 09:20:06 +02:00
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:
parent
584fef90ab
commit
c7f02d2c8e
2 changed files with 35 additions and 13 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue