|
| 1 | +/* Copyright 2025 Mozilla Foundation |
| 2 | + * |
| 3 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | + * you may not use this file except in compliance with the License. |
| 5 | + * You may obtain a copy of the License at |
| 6 | + * |
| 7 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | + * |
| 9 | + * Unless required by applicable law or agreed to in writing, software |
| 10 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | + * See the License for the specific language governing permissions and |
| 13 | + * limitations under the License. |
| 14 | + */ |
| 15 | + |
1 | 16 | import { Util } from "../shared/util.js"; |
2 | 17 |
|
3 | 18 | const FORCED_DEPENDENCY_LABEL = "__forcedDependency"; |
@@ -50,17 +65,11 @@ class BBoxReader { |
50 | 65 | } |
51 | 66 | } |
52 | 67 |
|
53 | | -const ensureDebugMetadata = (map, key) => { |
54 | | - if (!map) { |
55 | | - return undefined; |
56 | | - } |
57 | | - let value = map.get(key); |
58 | | - if (!value) { |
59 | | - value = { dependencies: new Set(), isRenderingOperation: false }; |
60 | | - map.set(key, value); |
61 | | - } |
62 | | - return value; |
63 | | -}; |
| 68 | +const ensureDebugMetadata = (map, key) => |
| 69 | + map?.getOrInsertComputed(key, () => ({ |
| 70 | + dependencies: new Set(), |
| 71 | + isRenderingOperation: false, |
| 72 | + })); |
64 | 73 |
|
65 | 74 | /** |
66 | 75 | * @typedef {"lineWidth" | "lineCap" | "lineJoin" | "miterLimit" | "dash" | |
|
0 commit comments