Skip to content

Commit

Permalink
Remove caching optimization. Better for a follow up if there are conc…
Browse files Browse the repository at this point in the history
…erns.
  • Loading branch information
ramonjd committed Aug 25, 2024
1 parent 06b1866 commit f0d4601
Showing 1 changed file with 1 addition and 18 deletions.
19 changes: 1 addition & 18 deletions packages/block-editor/src/utils/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,6 @@ export function getBlockClientId( node ) {
return blockNode.id.slice( 'block-'.length );
}

/*
* Cache for rectUnion() return values.
* When popovers are present on the canvas,
* this calculation function is called
* multiple times with the same values.
*/
const rectUnionCache = new Map();
/**
* Calculates the union of two rectangles, and optionally constrains this union within a containerRect's
* left and right values.
Expand All @@ -76,12 +69,6 @@ const rectUnionCache = new Map();
* @return {DOMRect} Union of the two rectangles.
*/
export function rectUnion( rect1, rect2, containerRect ) {
const cacheKey = JSON.stringify( { rect1, rect2, containerRect } );

if ( rectUnionCache.has( cacheKey ) ) {
return rectUnionCache.get( cacheKey );
}

let left = Math.min( rect1.left, rect2.left );
let right = Math.max( rect1.right, rect2.right );
const bottom = Math.max( rect1.bottom, rect2.bottom );
Expand All @@ -100,11 +87,7 @@ export function rectUnion( rect1, rect2, containerRect ) {
right = Math.min( right, containerRect.right );
}

const result = new window.DOMRect( left, top, right - left, bottom - top );

rectUnionCache.set( cacheKey, result );

return result;
return new window.DOMRect( left, top, right - left, bottom - top );
}

/**
Expand Down

0 comments on commit f0d4601

Please sign in to comment.