mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-05-31 07:11:00 +02:00
Compute a "proper" hash in the AnnotationStorage.prototype.modifiedIds getter
Currently the hash-property is just a stringified Array, which means that the hash-property can become arbitrarily long. That's not a good idea since it's used to compute a cache-key, in the API, which is then sent to the worker-thread. Hence the hash-property should be reasonably short, and its length should *not* depend on the number of modified editors, which can be achieved by using `MurmurHash3_64` here as well.
This commit is contained in:
parent
30d060c77a
commit
b72a229ee8
@ -303,9 +303,15 @@ class AnnotationStorage {
|
||||
ids.push(value.annotationElementId);
|
||||
}
|
||||
}
|
||||
let hash = "";
|
||||
if (ids.length) {
|
||||
const h = new MurmurHash3_64();
|
||||
h.update(ids.join(","));
|
||||
hash = h.hexdigest();
|
||||
}
|
||||
return (this.#modifiedIds = {
|
||||
ids: new Set(ids),
|
||||
hash: ids.join(","),
|
||||
hash,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user