mirror of
https://github.com/penpot/penpot.git
synced 2026-11-09 11:30:54 +00:00
💄 Prefer shorter form lambdas in obvious places
This commit is contained in:
parent
e00af05aab
commit
3716989e27
@ -337,9 +337,8 @@
|
||||
and `:software` identity fields."
|
||||
[ctx width height dpr renderer]
|
||||
(let [attrs (ex/ignoring (.getContextAttributes ^js ctx))
|
||||
attr (fn [k]
|
||||
(when (some? attrs)
|
||||
(unchecked-get attrs k)))
|
||||
attr #(when (some? attrs)
|
||||
(unchecked-get attrs %))
|
||||
vendor (graphics-string ctx "UNMASKED_VENDOR_WEBGL")]
|
||||
{:css-width width
|
||||
:css-height height
|
||||
@ -610,11 +609,9 @@
|
||||
[epoch params]
|
||||
(-> (ensure-module! (or (:module-url params) "./render-wasm.js")
|
||||
(or (:wasm-url params) "./render-wasm.wasm"))
|
||||
(.catch (fn [cause]
|
||||
(throw (ex-info (str "module init failed: "
|
||||
(or (ex-message cause) cause))
|
||||
{:phase "module-init"}
|
||||
cause))))
|
||||
(.catch #(throw (ex-info (str "module init failed: " (or (ex-message %) %))
|
||||
{:phase "module-init"}
|
||||
%)))
|
||||
(.then (fn [installed]
|
||||
(guard-current! epoch "module-init")
|
||||
installed))))
|
||||
@ -1042,7 +1039,7 @@
|
||||
(when (= epoch @owner-epoch*)
|
||||
(swap! prepared* assoc :busy? false))
|
||||
evidence))
|
||||
(.catch (fn [cause] (terminal-failure epoch cause "attempt"))))))))
|
||||
(.catch #(terminal-failure epoch % "attempt")))))))
|
||||
|
||||
(defn- encode-evidence
|
||||
"Encodes bridge evidence after timing and resolves failures as bridge
|
||||
|
||||
@ -278,8 +278,7 @@
|
||||
(let [{:keys [id frame-id]} *parent*]
|
||||
(register-ref! state label (:id shape))
|
||||
(swap! state
|
||||
(fn [scope]
|
||||
(ctst/add-shape (:id shape) shape scope frame-id id nil true)))))
|
||||
#(ctst/add-shape (:id shape) shape % frame-id id nil true))))
|
||||
|
||||
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Shape constructors
|
||||
|
||||
@ -118,9 +118,8 @@
|
||||
(decl/check-registered-scene! scene))
|
||||
(let [selected (->> (decl/cases)
|
||||
(map #(validate-case! % scene-by-id))
|
||||
(filter (fn [registered]
|
||||
(or (str/blank? pattern)
|
||||
(str/includes? (str (:id registered)) pattern))))
|
||||
(filter #(or (str/blank? pattern)
|
||||
(str/includes? (str (:id %)) pattern)))
|
||||
(mapv #(describe-case master-seed % (get scene-by-id (:scene %)))))]
|
||||
(when (empty? selected)
|
||||
(throw (ex-info "no benchmark cases match the selection"
|
||||
|
||||
@ -187,10 +187,9 @@
|
||||
:ns ns
|
||||
:existing-ns (:ns existing)})))
|
||||
(swap! registry
|
||||
(fn [reg]
|
||||
(cond-> (assoc-in reg [entries-key id] entry)
|
||||
(not (contains? (get reg entries-key) id))
|
||||
(update order-key conj id)))))
|
||||
#(cond-> (assoc-in % [entries-key id] entry)
|
||||
(not (contains? (get % entries-key) id))
|
||||
(update order-key conj id))))
|
||||
id)
|
||||
|
||||
(defn register-scene!
|
||||
|
||||
@ -175,9 +175,7 @@
|
||||
(.once child "exit"
|
||||
(fn [code signal]
|
||||
(resolve {:exit-code code :signal signal})))
|
||||
(.once child "error"
|
||||
(fn [cause]
|
||||
(resolve (spawn-failed cause))))))]
|
||||
(.once child "error" #(resolve (spawn-failed %)))))]
|
||||
(try
|
||||
(if-not (.-pid child)
|
||||
;; A failed spawn may not provide stdin/stdout/stderr at all.
|
||||
|
||||
@ -117,22 +117,20 @@
|
||||
(defn- change-config
|
||||
[record slug f]
|
||||
(update record :configurations
|
||||
(fn [configurations]
|
||||
(mapv (fn [configuration]
|
||||
(if (= slug (:slug configuration))
|
||||
(f configuration)
|
||||
configuration))
|
||||
configurations))))
|
||||
#(mapv (fn [config]
|
||||
(if (= slug (:slug config))
|
||||
(f config)
|
||||
config))
|
||||
%)))
|
||||
|
||||
(defn- change-edge
|
||||
[record from to f]
|
||||
(update record :edges
|
||||
(fn [edges]
|
||||
(mapv (fn [edge]
|
||||
(if (and (= from (:from edge)) (= to (:to edge)))
|
||||
(f edge)
|
||||
edge))
|
||||
edges))))
|
||||
#(mapv (fn [edge]
|
||||
(if (and (= from (:from edge)) (= to (:to edge)))
|
||||
(f edge)
|
||||
edge))
|
||||
%)))
|
||||
|
||||
(defn- config-by-slug
|
||||
[record slug]
|
||||
|
||||
@ -561,14 +561,13 @@
|
||||
additional-end
|
||||
base-end)))
|
||||
metadata (update (:metadata base) :diagnostics
|
||||
(fn [diagnostics]
|
||||
(assoc (or diagnostics {})
|
||||
:merge
|
||||
{:base-run-id (:run-id base)
|
||||
:additional-run-id (:run-id additional)
|
||||
:additional-warmups-excluded
|
||||
(count (filter :warmup? (:attempts additional)))
|
||||
:merged-at ended-at})))]
|
||||
#(assoc (or % {})
|
||||
:merge
|
||||
{:base-run-id (:run-id base)
|
||||
:additional-run-id (:run-id additional)
|
||||
:additional-warmups-excluded
|
||||
(count (filter :warmup? (:attempts additional)))
|
||||
:merged-at ended-at}))]
|
||||
(check-run {:type :run-record
|
||||
:run-id run-id
|
||||
:started-at (:started-at base)
|
||||
|
||||
@ -96,8 +96,7 @@
|
||||
{:pre [(valid-pan? options) (valid-view? (pan-view (:view rtx) dx dy))]}
|
||||
(let [target (pan-view (:view rtx) dx dy)]
|
||||
(-> (run-camera rtx target options)
|
||||
(.then (fn [evidence]
|
||||
(complete (assoc rtx :view target) (camera-evidence evidence))))
|
||||
(.then #(complete (assoc rtx :view target) (camera-evidence %)))
|
||||
(.catch fail))))
|
||||
|
||||
(defcommand load
|
||||
@ -113,9 +112,8 @@
|
||||
[rtx]
|
||||
(let [hooks (:hooks rtx)]
|
||||
(-> (protocol/drain hooks {:flags 0 :origin ((:now hooks)) :immediate false})
|
||||
(.then (fn [evidence]
|
||||
(complete rtx (assoc-in (render-evidence evidence)
|
||||
[:metrics :renderer/prepared-scene-to-full] [(:full-ms evidence)]))))
|
||||
(.then #(complete rtx (assoc-in (render-evidence %)
|
||||
[:metrics :renderer/prepared-scene-to-full] [(:full-ms %)])))
|
||||
(.catch fail))))
|
||||
|
||||
(defcommand zoom
|
||||
@ -132,8 +130,7 @@
|
||||
{:pre [(valid-zoom? options) (valid-view? (zoom-view (:view rtx) factor))]}
|
||||
(let [target (zoom-view (:view rtx) factor)]
|
||||
(-> (run-camera rtx target options)
|
||||
(.then (fn [evidence]
|
||||
(complete (assoc rtx :view target) (camera-evidence evidence))))
|
||||
(.then #(complete (assoc rtx :view target) (camera-evidence %)))
|
||||
(.catch fail))))
|
||||
|
||||
(defcommand restore
|
||||
@ -150,6 +147,5 @@
|
||||
{:pre [(valid-view? view)
|
||||
(= (decl/resolve-viewport view) (decl/resolve-viewport (:view rtx)))]}
|
||||
(-> (protocol/restore (:hooks rtx) view)
|
||||
(.then (fn [evidence]
|
||||
(complete (assoc rtx :view view) (render-evidence evidence))))
|
||||
(.then #(complete (assoc rtx :view view) (render-evidence %)))
|
||||
(.catch fail)))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user