Use Map.prototype.getOrInsertComputed() in the ensureDebugMetadata helper

Also, shorten the function by using optional chaining.
This commit is contained in:
Jonas Jenwald 2026-02-21 12:00:19 +01:00
parent f548a159d6
commit c7bdf5b508

View File

@ -50,17 +50,11 @@ class BBoxReader {
}
}
const ensureDebugMetadata = (map, key) => {
if (!map) {
return undefined;
}
let value = map.get(key);
if (!value) {
value = { dependencies: new Set(), isRenderingOperation: false };
map.set(key, value);
}
return value;
};
const ensureDebugMetadata = (map, key) =>
map?.getOrInsertComputed(key, () => ({
dependencies: new Set(),
isRenderingOperation: false,
}));
/**
* @typedef {"lineWidth" | "lineCap" | "lineJoin" | "miterLimit" | "dash" |