소스 검색

fix: perf regression in `getCommonBounds` (#8429)

David Luzar 1 년 전
부모
커밋
5facc0d6da
1개의 변경된 파일3개의 추가작업 그리고 4개의 파일을 삭제
  1. 3 4
      packages/excalidraw/element/bounds.ts

+ 3 - 4
packages/excalidraw/element/bounds.ts

@@ -749,11 +749,10 @@ export const getCommonBounds = (
   let minY = Infinity;
   let maxY = -Infinity;
 
+  const _elementsMap = elementsMap || arrayToMap(elements);
+
   elements.forEach((element) => {
-    const [x1, y1, x2, y2] = getElementBounds(
-      element,
-      elementsMap || arrayToMap(elements),
-    );
+    const [x1, y1, x2, y2] = getElementBounds(element, _elementsMap);
     minX = Math.min(minX, x1);
     minY = Math.min(minY, y1);
     maxX = Math.max(maxX, x2);