Skip to content

Commit 5ea4f3e

Browse files
committed
doit => run!
1 parent 302b179 commit 5ea4f3e

File tree

4 files changed

+37
-55
lines changed

4 files changed

+37
-55
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66

77
* #78(liquidz): Add missing chrono fields (v0.3.3 has breaking changes)
88
* #81(terop): Remove clj-tuple - no advantages over Clojure vector anymore
9-
* Remove java-time.util/get-static-fields-of-type
9+
* Remove `java-time.util/get-static-fields-of-type`
1010
* set Java property `java-time.util.get-static-fields-of-type=true` to revert
11+
* Remove `java-time.potemkin.util/doit`
12+
* set Java property `java-time.potemkin.util/doit=true` to revert
1113

1214
## 0.3.3
1315

bin/bb-test-runner.clj

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,10 @@
33
(:require [clojure.test :as t]
44
[babashka.classpath :as cp]))
55

6-
(def require-nsyms ['java-time.potemkin.util
7-
'java-time.potemkin.namespaces
8-
'java-time.joda
9-
'java-time.core
10-
'java-time.properties
11-
'java-time.util
12-
'java-time.temporal
13-
'java-time.amount
14-
'java-time.zone
15-
'java-time.single-field
16-
'java-time.local
17-
'java-time.chrono
18-
'java-time.convert
19-
'java-time.sugar
20-
'java-time.seqs
21-
'java-time.adjuster
22-
'java-time.interval
23-
'java-time.format
24-
'java-time.clock
25-
'java-time.pre-java8
26-
'java-time
27-
])
28-
;;TODO
29-
(def test-nsyms [#_'java-time-test
30-
#_'java-time.graph-test])
6+
(def test-nsyms ['java-time-test
7+
'java-time.graph-test])
318

32-
(some->> (seq (concat require-nsyms test-nsyms))
9+
(some->> (seq test-nsyms)
3310
(apply require))
3411

3512
(def test-results

src/java_time/graph.cljc

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -111,14 +111,15 @@
111111

112112
(defn- search-for-possible-sources
113113
[vresult m types-so-far k more-arity-steps]
114-
(u/doit [[t r] m]
115-
(when (assignable-type? k t)
116-
(if-not more-arity-steps
117-
(vswap! vresult concat (mapv #(as-source types-so-far t %) r))
118-
(search-for-possible-sources vresult r
119-
(conj types-so-far t)
120-
(first more-arity-steps)
121-
(next more-arity-steps))))))
114+
(run! (fn [[t r]]
115+
(when (assignable-type? k t)
116+
(if-not more-arity-steps
117+
(vswap! vresult concat (mapv #(as-source types-so-far t %) r))
118+
(search-for-possible-sources vresult r
119+
(conj types-so-far t)
120+
(first more-arity-steps)
121+
(next more-arity-steps)))))
122+
m))
122123

123124
(defn- collect-targets [v]
124125
(reduce
@@ -193,8 +194,8 @@
193194
(let [path (ConversionPath. (vector) (vector) #{src} 0)]
194195
(if (assignable? src dst)
195196
path
196-
(let [q #?(:bb (atom (list path))
197-
:default (doto (PriorityQueue.) (.add path)))
197+
(let [q #?(:bb (atom ())
198+
:default (PriorityQueue.))
198199
add #?(:bb #(swap! q (fn [prev]
199200
(sort-by (fn [^ConversionPath p]
200201
[(.cost p) (count (.path p))])
@@ -203,18 +204,19 @@
203204
:default #(.add q %))
204205
poll #?(:bb #(-> (swap-vals! q next) first first)
205206
:default #(.poll q))
207+
_ (add path)
206208
dsts (equivalent-targets g dst)]
207209
(loop []
208-
(when-let [^ConversionPath p (poll)]
210+
(when-some [^ConversionPath p (poll)]
209211
(let [curr (or (-> p .path last second) src)]
210212
(if (some #(assignable? curr %) dsts)
211213
p
212-
(do
213-
(u/doit [[[src dst] c] (possible-conversions g curr)]
214-
(when (and (> max-path-length (count (.path p)))
215-
(not ((.visited? p) dst)))
216-
(add (conj-path p src dst c))))
217-
(recur)))))))))))
214+
(do (run! (fn [[[src dst] c]]
215+
(when (and (> max-path-length (count (.path p)))
216+
(not ((.visited? p) dst)))
217+
(add (conj-path p src dst c))))
218+
(possible-conversions g curr))
219+
(recur)))))))))))
218220

219221
(defn- replace-range [v replacement idxs]
220222
(concat (subvec v 0 (first idxs))

src/java_time/potemkin/util.cljc

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,15 @@
6565
(let [v (de-nil (apply f k))]
6666
(or (.putIfAbsent m k v) v))))))))))
6767

68-
(defmacro doit
69-
"A version of doseq that doesn't emit all that inline-destroying chunked-seq code."
70-
[[x it] & body]
71-
(let [it-sym (gensym "iterable")]
72-
`(let [~it-sym ~it
73-
it# (.iterator ~(with-meta it-sym {:tag 'java.lang.Iterable}))]
74-
(loop []
75-
(when (.hasNext it#)
76-
(let [~x (.next it#)]
77-
~@body)
78-
(recur))))))
68+
(when (some-> (System/getProperty "java-time.potemkin.util.doit") (= "true"))
69+
(defmacro doit
70+
"A version of doseq that doesn't emit all that inline-destroying chunked-seq code."
71+
[[x it] & body]
72+
(let [it-sym (gensym "iterable")]
73+
`(let [~it-sym ~it
74+
it# (.iterator ~(with-meta it-sym {:tag 'java.lang.Iterable}))]
75+
(loop []
76+
(when (.hasNext it#)
77+
(let [~x (.next it#)]
78+
~@body)
79+
(recur)))))))

0 commit comments

Comments
 (0)