mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-07-25 08:27:19 +02:00
Use Map.prototype.getOrInsertComputed more in the web/ folder
This commit is contained in:
parent
6e18a52b86
commit
6d7bca521b
@ -733,11 +733,9 @@ class TreeView {
|
|||||||
spinner.textContent = "Loading…";
|
spinner.textContent = "Loading…";
|
||||||
childrenEl.append(spinner);
|
childrenEl.append(spinner);
|
||||||
this.#onMarkLoading(1);
|
this.#onMarkLoading(1);
|
||||||
if (!this.#refCache.has(cacheKey)) {
|
|
||||||
this.#refCache.set(cacheKey, doc.getRawData({ ref }));
|
|
||||||
}
|
|
||||||
this.#refCache
|
this.#refCache
|
||||||
.get(cacheKey)
|
.getOrInsertComputed(cacheKey, () => doc.getRawData({ ref }))
|
||||||
.then(result => {
|
.then(result => {
|
||||||
childrenEl.replaceChildren();
|
childrenEl.replaceChildren();
|
||||||
this.#buildChildren(result, doc, childrenEl);
|
this.#buildChildren(result, doc, childrenEl);
|
||||||
|
|||||||
@ -217,11 +217,10 @@ function normalize(text, options = {}) {
|
|||||||
|
|
||||||
if (p2) {
|
if (p2) {
|
||||||
// Use the NFKC representation to normalize the char.
|
// Use the NFKC representation to normalize the char.
|
||||||
let replacement = NFKC_CHARS_TO_NORMALIZE.get(p2);
|
const replacement = NFKC_CHARS_TO_NORMALIZE.getOrInsertComputed(
|
||||||
if (!replacement) {
|
p2,
|
||||||
replacement = p2.normalize("NFKC");
|
() => p2.normalize("NFKC")
|
||||||
NFKC_CHARS_TO_NORMALIZE.set(p2, replacement);
|
);
|
||||||
}
|
|
||||||
const jj = replacement.length;
|
const jj = replacement.length;
|
||||||
for (let j = 1; j < jj; j++) {
|
for (let j = 1; j < jj; j++) {
|
||||||
positions.push(i - shift + j, shift - j);
|
positions.push(i - shift + j, shift - j);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user