mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-07-24 16:07:22 +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) {
|
_addNamespacePrefix(prefixes) {
|
||||||
for (const { prefix, value } of prefixes) {
|
for (const { prefix, value } of prefixes) {
|
||||||
const namespace = this._searchNamespace(value);
|
const namespace = this._searchNamespace(value);
|
||||||
let prefixStack = this._namespacePrefixes.get(prefix);
|
this._namespacePrefixes.getOrInsert(prefix, []).push(namespace);
|
||||||
if (!prefixStack) {
|
|
||||||
prefixStack = [];
|
|
||||||
this._namespacePrefixes.set(prefix, prefixStack);
|
|
||||||
}
|
|
||||||
prefixStack.push(namespace);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -48,14 +48,11 @@ class FontFinder {
|
|||||||
addPdfFont(pdfFont) {
|
addPdfFont(pdfFont) {
|
||||||
const cssFontInfo = pdfFont.cssFontInfo;
|
const cssFontInfo = pdfFont.cssFontInfo;
|
||||||
const name = cssFontInfo.fontFamily;
|
const name = cssFontInfo.fontFamily;
|
||||||
let font = this.fonts.get(name);
|
const font = this.fonts.getOrInsertComputed(name, () =>
|
||||||
if (!font) {
|
Object.create(null)
|
||||||
font = Object.create(null);
|
);
|
||||||
this.fonts.set(name, font);
|
this.defaultFont ??= font;
|
||||||
if (!this.defaultFont) {
|
|
||||||
this.defaultFont = font;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let property = "";
|
let property = "";
|
||||||
const fontWeight = parseFloat(cssFontInfo.fontWeight);
|
const fontWeight = parseFloat(cssFontInfo.fontWeight);
|
||||||
if (parseFloat(cssFontInfo.italicAngle) !== 0) {
|
if (parseFloat(cssFontInfo.italicAngle) !== 0) {
|
||||||
|
|||||||
@ -193,11 +193,7 @@ function searchNode(
|
|||||||
let children, cached;
|
let children, cached;
|
||||||
|
|
||||||
if (useCache) {
|
if (useCache) {
|
||||||
cached = somCache.get(node);
|
cached = somCache.getOrInsertComputed(node, () => new Map());
|
||||||
if (!cached) {
|
|
||||||
cached = new Map();
|
|
||||||
somCache.set(node, cached);
|
|
||||||
}
|
|
||||||
children = cached.get(cacheName);
|
children = cached.get(cacheName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user