mirror of
https://github.com/penpot/penpot.git
synced 2026-11-16 15:11:17 +00:00
⚡ Memoize boards with grids in frame-grid* (#13075)
On a test file `mem_benchmark` with 30k boards on one page, around 11ms is spent each time the view is panned/zoomed iterating over each board and checking has-grid?, which after https://github.com/penpot/penpot/pull/12790 is now slightly slower because it involves an array scan. We don't need to compute the list of boards with grids on every step of the pan and can memoize it, which saves 30k calls to has-grid? on each frame. AI-assisted-by: claude-opus-5-5
This commit is contained in:
parent
bd4af28d78
commit
a224608a0e
@ -167,8 +167,9 @@
|
||||
(mf/defc frame-grid*
|
||||
{::mf/wrap [mf/memo]}
|
||||
[{:keys [zoom transform selected focus vbox clip-rulers] :or {clip-rulers false}}]
|
||||
(let [frames (->> (mf/deref refs/workspace-frames)
|
||||
(filter has-grid?))
|
||||
(let [frames (mf/deref refs/workspace-frames)
|
||||
frames (mf/with-memo [frames]
|
||||
(into [] (filter has-grid?) frames))
|
||||
transforming (when (some? transform) selected)]
|
||||
|
||||
[:g.grid-display {:style {:pointer-events "none"}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user