From f6e9c398b0406be5099d2a971906be80745112f6 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Mon, 19 Jun 2023 19:12:10 +0200 Subject: [PATCH] :zap: Improve performance of absolute-move function --- common/src/app/common/geom/shapes/transforms.cljc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/common/src/app/common/geom/shapes/transforms.cljc b/common/src/app/common/geom/shapes/transforms.cljc index d7f51ff64..2399c1a7c 100644 --- a/common/src/app/common/geom/shapes/transforms.cljc +++ b/common/src/app/common/geom/shapes/transforms.cljc @@ -101,9 +101,14 @@ (defn absolute-move "Move the shape to the exactly specified position." - [shape {:keys [x y]}] - (let [dx (- (d/check-num x) (-> shape :selrect :x)) - dy (- (d/check-num y) (-> shape :selrect :y))] + [shape pos] + (let [x (dm/get-prop pos :x) + y (dm/get-prop pos :y) + sr (dm/get-prop shape selrect) + px (dm/get-prop sr :x) + py (dm/get-prop sr :y) + dx (- (d/check-num x) px) + dy (- (d/check-num y) py)] (move shape (gpt/point dx dy)))) ; ---- Geometric operations