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