From ef3a47b492507f54d435df086cc2277b7deea299 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Mon, 26 Aug 2024 15:45:32 +0200 Subject: [PATCH] :zap: Add efficiency changes to get-segments helper --- frontend/src/app/util/path/tools.cljs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/frontend/src/app/util/path/tools.cljs b/frontend/src/app/util/path/tools.cljs index 9bd413494..78d106400 100644 --- a/frontend/src/app/util/path/tools.cljs +++ b/frontend/src/app/util/path/tools.cljs @@ -184,18 +184,22 @@ cur-cmd (first content) content (rest content)] - (let [;; Close-path makes a segment from the last point to the initial path point - cur-point (if (= :close-path (:command cur-cmd)) + (let [command (:command cur-cmd) + close-path? (= command :close-path) + move-to? (= command :move-to) + + ;; Close-path makes a segment from the last point to the initial path point + cur-point (if close-path? start-point (upc/command->point cur-cmd)) ;; If there is a move-to we don't have a segment - prev-point (if (= :move-to (:command cur-cmd)) + prev-point (if move-to? nil prev-point) ;; We update the start point - start-point (if (= :move-to (:command cur-cmd)) + start-point (if move-to? cur-point start-point)