Optimize wireframe mode

Summary: I noticed a slow down when using key board controls as this would change the selection. this adds the optimization back when wireframe mode == All

Reviewed By: antonk52

Differential Revision: D47949836

fbshipit-source-id: a08e5608c159d23b8a0afed419724c02231718d6
This commit is contained in:
Luke De Feo
2023-08-01 10:32:29 -07:00
committed by Facebook GitHub Bot
parent 4e7ca39168
commit 9932d28b2f

View File

@@ -248,11 +248,17 @@ export const Visualization2D: React.FC<
const MemoedVisualizationNode2D = React.memo(
Visualization2DNode,
(prev, next) => {
return (
prev.node === next.node &&
prev.selectedNode === next.selectedNode &&
prev.wireframeMode === next.wireframeMode
);
if (prev.node != next.node || prev.wireframeMode != next.wireframeMode) {
return false;
}
if (next.wireframeMode == 'All') {
//if all wire frames are drawn and the root node is the same
//then we are safe
return true;
} else {
//with other modes the selected node affects the drawing
return prev.selectedNode === next.selectedNode;
}
},
);
@@ -288,7 +294,7 @@ function Visualization2DNode({
}
const children = nestedChildren.map((child) => (
<MemoedVisualizationNode2D
<Visualization2DNode
wireframeMode={wireframeMode}
selectedNode={selectedNode}
isSelectedOrChildOrSelected={isSelected || isSelectedOrChildOrSelected}