mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-20 15:18:08 +02:00
Represent cid chars using integers, not strings.
cid chars are 16-bit unsigned integers. Currently we convert them to single-char strings when inserting them into the CMap, and then convert them back to integers when extracting them from the CMap. This patch changes CMap so that cid chars stay in integer format throughout, saving both time and space. When loading the PDF from issue #4580, this change reduces peak RSS from ~600 to ~370 MiB. It also improves overall speed on that PDF by ~26%, going from 724 ms to 533 ms.
This commit is contained in:
parent
ad2ea78280
commit
adf58ed687
3 changed files with 46 additions and 37 deletions
|
@ -44,7 +44,7 @@ describe('cmap', function() {
|
|||
'endcidchar\n';
|
||||
var stream = new StringStream(str);
|
||||
var cmap = CMapFactory.create(stream);
|
||||
expect(cmap.lookup(0x14)).toEqual(String.fromCharCode(0x00));
|
||||
expect(cmap.lookup(0x14)).toEqual(0x00);
|
||||
expect(cmap.lookup(0x15)).toBeUndefined();
|
||||
});
|
||||
it('parses begincidrange', function() {
|
||||
|
@ -54,8 +54,8 @@ describe('cmap', function() {
|
|||
var stream = new StringStream(str);
|
||||
var cmap = CMapFactory.create(stream);
|
||||
expect(cmap.lookup(0x15)).toBeUndefined();
|
||||
expect(cmap.lookup(0x16)).toEqual(String.fromCharCode(0x00));
|
||||
expect(cmap.lookup(0x1B)).toEqual(String.fromCharCode(0x05));
|
||||
expect(cmap.lookup(0x16)).toEqual(0x00);
|
||||
expect(cmap.lookup(0x1B)).toEqual(0x05);
|
||||
expect(cmap.lookup(0x1C)).toBeUndefined();
|
||||
});
|
||||
it('decodes codespace ranges', function() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue