Skip to main content

Hi !


I would like to know when i do node.width or node.height,

if within the Figma API, the retrieval of this information is O(1) or more.

in other words, is it precalculated, and available as a data to be just returned ?

or does this triggers some calculations involving loops over the children (and potentially recursive)


and if it does, is it internally cached to avoid recalculating it twice ? (if nothing was written in between)


thanks in advance for the insight !

H there,


Thanks for reaching out. I’m checking with our internal team, and I’ll get back to you if there is anything I can share with you!


Thanks,

Toku


Hi there,


As I checked with our internal team, we don’t do any recursive traversal to calculate the size. Why not always O(1)? When interacting with a node object, sometimes we need to make sure that that the node is in a “clean” state before reading its properties.


I hope it helps. We will keep improving with your feedback!


Thanks,

Toku


Thank you very much for your answer and sorry for the super late reply,


so can i assume that if querying the width/height of a specific node 2 times in a row, the 2nd time will be O(1), it’s only if the user (designer) modifies the node or a child that it gets labeled as “dirty” and triggers some recalculations


@Vincent_Huss thanks for the reply! Yes, you can assume that getting the width/height should be O(1) most of the time.


I hope it helps!


Thanks,

Toku


Reply