Reduce usage of Date.now() in src/core/worker.js

Currently for every single parsed/rendered page there's no less than *four* `Date.now()` calls being made on the worker-side. This seems totally unnecessary, since the result of these calls are, by default, not used for anything *unless* the verbosity level is set to `INFO`.
This commit is contained in:
Jonas Jenwald 2019-03-02 11:36:30 +01:00
parent c43396c2b7
commit 4170c414fa
2 changed files with 22 additions and 15 deletions

View file

@ -2028,11 +2028,11 @@ class WorkerTransport {
return; // Ignore any pending requests if the worker was terminated.
}
const page = this.pageCache[data.pageNum - 1];
const page = this.pageCache[data.pageIndex];
const intentState = page.intentStates[data.intent];
if (intentState.displayReadyCapability) {
intentState.displayReadyCapability.reject(data.error);
intentState.displayReadyCapability.reject(new Error(data.error));
} else {
throw new Error(data.error);
}