Skip to content

Commit 2eb8795

Browse files
authored
Merge pull request #239 from LuisThiamNye/patch-perf-sort
Refactor indents sorting to improve performance
2 parents 3eccdf1 + 80d6a8f commit 2eb8795

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

cljfmt/src/cljfmt/core.cljc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@
312312
(defn- custom-indent [zloc indents context]
313313
(if (empty? indents)
314314
(list-indent zloc)
315-
(let [indenter (->> (sort-by indent-order indents)
315+
(let [indenter (->> indents
316316
(map #(make-indenter % context))
317317
(apply some-fn))]
318318
(or (indenter zloc)
@@ -342,10 +342,11 @@
342342
([form indents]
343343
(indent form indents {}))
344344
([form indents alias-map]
345-
(let [ns-name (find-namespace (z/edn form))]
345+
(let [ns-name (find-namespace (z/edn form))
346+
sorted-indents (sort-by indent-order indents)]
346347
(transform form edit-all should-indent?
347-
#(indent-line % indents {:alias-map alias-map
348-
:ns-name ns-name})))))
348+
#(indent-line % sorted-indents {:alias-map alias-map
349+
:ns-name ns-name})))))
349350

350351
(defn- map-key? [zloc]
351352
(and (z/map? (z/up zloc))

0 commit comments

Comments
 (0)