Merge pull request #20706 from Snuffleupagus/ensureDebugMetadata-getOrInsertComputed

Use `Map.prototype.getOrInsertComputed()` in the `ensureDebugMetadata` helper
This commit is contained in:
Jonas Jenwald 2026-02-22 10:35:44 +01:00 committed by GitHub
commit ad0a310394
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,3 +1,18 @@
/* Copyright 2025 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Util } from "../shared/util.js";
const FORCED_DEPENDENCY_LABEL = "__forcedDependency";
@ -50,17 +65,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" |