Merge pull request #14873 from Snuffleupagus/AnnotationStorage-hash
Replace the `AnnotationStorage.lastModified`-getter with a proper hash-method
This commit is contained in:
commit
8b8a09e52f
@ -75,7 +75,7 @@ import { DecodeStream } from "./decode_stream.js";
|
|||||||
import { getGlyphsUnicode } from "./glyphlist.js";
|
import { getGlyphsUnicode } from "./glyphlist.js";
|
||||||
import { getLookupTableFactory } from "./core_utils.js";
|
import { getLookupTableFactory } from "./core_utils.js";
|
||||||
import { getMetrics } from "./metrics.js";
|
import { getMetrics } from "./metrics.js";
|
||||||
import { MurmurHash3_64 } from "./murmurhash3.js";
|
import { MurmurHash3_64 } from "../shared/murmurhash3.js";
|
||||||
import { OperatorList } from "./operator_list.js";
|
import { OperatorList } from "./operator_list.js";
|
||||||
import { PDFImage } from "./image.js";
|
import { PDFImage } from "./image.js";
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { MurmurHash3_64 } from "../shared/murmurhash3.js";
|
||||||
import { objectFromMap } from "../shared/util.js";
|
import { objectFromMap } from "../shared/util.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -21,7 +22,6 @@ import { objectFromMap } from "../shared/util.js";
|
|||||||
class AnnotationStorage {
|
class AnnotationStorage {
|
||||||
constructor() {
|
constructor() {
|
||||||
this._storage = new Map();
|
this._storage = new Map();
|
||||||
this._timeStamp = Date.now();
|
|
||||||
this._modified = false;
|
this._modified = false;
|
||||||
|
|
||||||
// Callbacks to signal when the modification state is set or reset.
|
// Callbacks to signal when the modification state is set or reset.
|
||||||
@ -85,7 +85,6 @@ class AnnotationStorage {
|
|||||||
this._storage.set(key, value);
|
this._storage.set(key, value);
|
||||||
}
|
}
|
||||||
if (modified) {
|
if (modified) {
|
||||||
this._timeStamp = Date.now();
|
|
||||||
this._setModified();
|
this._setModified();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -131,8 +130,13 @@ class AnnotationStorage {
|
|||||||
* PLEASE NOTE: Only intended for usage within the API itself.
|
* PLEASE NOTE: Only intended for usage within the API itself.
|
||||||
* @ignore
|
* @ignore
|
||||||
*/
|
*/
|
||||||
get lastModified() {
|
get hash() {
|
||||||
return this._timeStamp.toString();
|
const hash = new MurmurHash3_64();
|
||||||
|
|
||||||
|
for (const [key, value] of this._storage) {
|
||||||
|
hash.update(`${key}:${JSON.stringify(value)}`);
|
||||||
|
}
|
||||||
|
return hash.hexdigest();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2402,7 +2402,7 @@ class WorkerTransport {
|
|||||||
isOpList = false
|
isOpList = false
|
||||||
) {
|
) {
|
||||||
let renderingIntent = RenderingIntentFlag.DISPLAY; // Default value.
|
let renderingIntent = RenderingIntentFlag.DISPLAY; // Default value.
|
||||||
let lastModified = "";
|
let annotationHash = "";
|
||||||
|
|
||||||
switch (intent) {
|
switch (intent) {
|
||||||
case "any":
|
case "any":
|
||||||
@ -2429,7 +2429,7 @@ class WorkerTransport {
|
|||||||
case AnnotationMode.ENABLE_STORAGE:
|
case AnnotationMode.ENABLE_STORAGE:
|
||||||
renderingIntent += RenderingIntentFlag.ANNOTATIONS_STORAGE;
|
renderingIntent += RenderingIntentFlag.ANNOTATIONS_STORAGE;
|
||||||
|
|
||||||
lastModified = this.annotationStorage.lastModified;
|
annotationHash = this.annotationStorage.hash;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
warn(`getRenderingIntent - invalid annotationMode: ${annotationMode}`);
|
warn(`getRenderingIntent - invalid annotationMode: ${annotationMode}`);
|
||||||
@ -2441,7 +2441,7 @@ class WorkerTransport {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
renderingIntent,
|
renderingIntent,
|
||||||
cacheKey: `${renderingIntent}_${lastModified}`,
|
cacheKey: `${renderingIntent}_${annotationHash}`,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
* Hashes roughly 100 KB per millisecond on i7 3.4 GHz.
|
* Hashes roughly 100 KB per millisecond on i7 3.4 GHz.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { isArrayBuffer } from "../shared/util.js";
|
import { isArrayBuffer } from "./util.js";
|
||||||
|
|
||||||
const SEED = 0xc3d2e1f0;
|
const SEED = 0xc3d2e1f0;
|
||||||
// Workaround for missing math precision in JS.
|
// Workaround for missing math precision in JS.
|
@ -13,7 +13,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { MurmurHash3_64 } from "../../src/core/murmurhash3.js";
|
import { MurmurHash3_64 } from "../../src/shared/murmurhash3.js";
|
||||||
|
|
||||||
describe("MurmurHash3_64", function () {
|
describe("MurmurHash3_64", function () {
|
||||||
it("instantiates without seed", function () {
|
it("instantiates without seed", function () {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user