mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-04-13 16:54:03 +02:00
Use Map.prototype.getOrInsertComputed() in the src/core/xfa/ folder
This commit is contained in:
parent
909a700afa
commit
c2f5e19eb0
@ -166,12 +166,7 @@ class Builder {
|
||||
_addNamespacePrefix(prefixes) {
|
||||
for (const { prefix, value } of prefixes) {
|
||||
const namespace = this._searchNamespace(value);
|
||||
let prefixStack = this._namespacePrefixes.get(prefix);
|
||||
if (!prefixStack) {
|
||||
prefixStack = [];
|
||||
this._namespacePrefixes.set(prefix, prefixStack);
|
||||
}
|
||||
prefixStack.push(namespace);
|
||||
this._namespacePrefixes.getOrInsert(prefix, []).push(namespace);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -48,14 +48,11 @@ class FontFinder {
|
||||
addPdfFont(pdfFont) {
|
||||
const cssFontInfo = pdfFont.cssFontInfo;
|
||||
const name = cssFontInfo.fontFamily;
|
||||
let font = this.fonts.get(name);
|
||||
if (!font) {
|
||||
font = Object.create(null);
|
||||
this.fonts.set(name, font);
|
||||
if (!this.defaultFont) {
|
||||
this.defaultFont = font;
|
||||
}
|
||||
}
|
||||
const font = this.fonts.getOrInsertComputed(name, () =>
|
||||
Object.create(null)
|
||||
);
|
||||
this.defaultFont ??= font;
|
||||
|
||||
let property = "";
|
||||
const fontWeight = parseFloat(cssFontInfo.fontWeight);
|
||||
if (parseFloat(cssFontInfo.italicAngle) !== 0) {
|
||||
|
||||
@ -193,11 +193,7 @@ function searchNode(
|
||||
let children, cached;
|
||||
|
||||
if (useCache) {
|
||||
cached = somCache.get(node);
|
||||
if (!cached) {
|
||||
cached = new Map();
|
||||
somCache.set(node, cached);
|
||||
}
|
||||
cached = somCache.getOrInsertComputed(node, () => new Map());
|
||||
children = cached.get(cacheName);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user