mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-26 10:08:06 +02:00
Merge pull request #11118 from Snuffleupagus/FetchBuiltInCMap-sendWithStream
Transfer, rather than copy, CMap data to the worker-thread
This commit is contained in:
commit
37d5b80ba8
2 changed files with 36 additions and 5 deletions
|
@ -78,8 +78,24 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||
if (this.builtInCMapCache.has(name)) {
|
||||
return this.builtInCMapCache.get(name);
|
||||
}
|
||||
const data = await this.handler.sendWithPromise('FetchBuiltInCMap',
|
||||
{ name, });
|
||||
const readableStream = this.handler.sendWithStream('FetchBuiltInCMap', {
|
||||
name,
|
||||
});
|
||||
const reader = readableStream.getReader();
|
||||
|
||||
const data = await new Promise(function(resolve, reject) {
|
||||
function pump() {
|
||||
reader.read().then(function({ value, done, }) {
|
||||
if (done) {
|
||||
return;
|
||||
}
|
||||
resolve(value);
|
||||
pump();
|
||||
}, reject);
|
||||
}
|
||||
pump();
|
||||
});
|
||||
|
||||
if (data.compressionType !== CMapCompressionType.NONE) {
|
||||
// Given the size of uncompressed CMaps, only cache compressed ones.
|
||||
this.builtInCMapCache.set(name, data);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue