1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-25 17:48:07 +02:00

Add caching to reduce the number of Ref objects

This is similar to the existing caching used to reduced the number of `Cmd` and `Name` objects.
With the `tracemonkey.pdf` file, this patch changes the number of `Ref` objects as follows (in the default viewer):

|          | Loading the first page | Loading *all* the pages |
|----------|------------------------|-------------------------|
| `master` | 332                    | 3265                    |
| `patch`  | 163                    | 996                     |
This commit is contained in:
Jonas Jenwald 2019-05-25 17:40:14 +02:00
parent d95145953c
commit 2fe9f3ff8f
9 changed files with 103 additions and 88 deletions

View file

@ -150,7 +150,7 @@ class Parser {
if (Number.isInteger(buf1)) { // indirect reference or integer
const num = buf1;
if (Number.isInteger(this.buf1) && isCmd(this.buf2, 'R')) {
const ref = new Ref(num, this.buf1);
const ref = Ref.get(num, this.buf1);
this.shift();
this.shift();
return ref;