From da2f51980543272072239f5ed7b0035230321562 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Thu, 3 Apr 2025 00:12:13 +0200 Subject: [PATCH] :zap: Add `get-points` helper, a faster alternative to `content->points` --- common/src/app/common/types/path/segment.cljc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/common/src/app/common/types/path/segment.cljc b/common/src/app/common/types/path/segment.cljc index 5f3198ed96..9e081e373f 100644 --- a/common/src/app/common/types/path/segment.cljc +++ b/common/src/app/common/types/path/segment.cljc @@ -166,6 +166,16 @@ (some->> (seq content) (into [] (keep segment->point))))) +(defn get-points + "Returns points for the given segment, faster version of + the `content->points`." + [content] + (impl/with-cache content "get-points" + (impl/-walk content + (fn [type _ _ _ _ x y] + (when (not= type :close-path) + (gpt/point x y)))))) + (defn segments->content ([segments] (segments->content segments false))