Fix caching of small inline images in Parser.makeInlineImage (issue 8790)

*Follow-up to PR 5445.*

Using the PDF file from issue 2618, i.e. http://bugzilla-attachments.gnome.org/attachment.cgi?id=226471, with the following manifest file:
```json
[
    {  "id": "issue2618",
       "file": "../web/pdfs/issue2618.pdf",
       "md5": "",
       "rounds": 50,
       "type": "eq"
    }
]
```
I get the following results when comparing `master` against this patch:
```
browser | stat         | Count | Baseline(ms) | Current(ms) |  +/- |     %  | Result(P<.05)
------- | ------------ | ----- | ------------ | ----------- | ---- | ------ | -------------
firefox | Overall      |    50 |         4694 |        3974 | -721 | -15.35 |        faster
firefox | Page Request |    50 |            2 |           1 |    0 | -22.83 |
firefox | Rendering    |    50 |         4692 |        3972 | -720 | -15.35 |        faster
```

So, based on these results, it seems like a fairly clear win to fix this broken caching :-)
This commit is contained in:
Jonas Jenwald 2017-08-18 22:50:00 +02:00
parent 8c8d8fa239
commit 2112999db7

View File

@ -398,12 +398,13 @@ var Parser = (function ParserClosure() {
} }
adler32 = ((b % 65521) << 16) | (a % 65521); adler32 = ((b % 65521) << 16) | (a % 65521);
if (this.imageCache.adler32 === adler32) { let cacheEntry = this.imageCache[adler32];
if (cacheEntry !== undefined) {
this.buf2 = Cmd.get('EI'); this.buf2 = Cmd.get('EI');
this.shift(); this.shift();
this.imageCache[adler32].reset(); cacheEntry.reset();
return this.imageCache[adler32]; return cacheEntry;
} }
} }