From 2c61cfd1398fce331beec7395c039bf43018688c Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Wed, 5 Jul 2023 12:53:21 +0200 Subject: [PATCH] :zap: Optimize content->points helper --- common/src/app/common/geom/shapes/path.cljc | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/common/src/app/common/geom/shapes/path.cljc b/common/src/app/common/geom/shapes/path.cljc index a80cdb581..7497ef87e 100644 --- a/common/src/app/common/geom/shapes/path.cljc +++ b/common/src/app/common/geom/shapes/path.cljc @@ -46,11 +46,14 @@ (defn content->points "Returns the points in the given content" [content] - (->> content - (map #(when (-> % :params :x) - (gpt/point (-> % :params :x) (-> % :params :y)))) - (remove nil?) - (into []))) + (letfn [(segment->point [seg] + (let [params (get seg :params) + x (get params :x) + y (get params :y)] + (when (d/num? x y) + (gpt/point x y))))] + (some->> (seq content) + (into [] (keep segment->point))))) (defn line-values [[from-p to-p] t]