Skip to content

Commit 00b1360

Browse files
committed
Merge in 'and' optimization from master branch
Fixes #3 Signed-off-by: Sean Corfield <[email protected]>
1 parent 8502ef3 commit 00b1360

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
## CHANGES
22

3+
* v0.13.next in progress
4+
* address [clj-commons/slingshot#3](https://github.com/clj-commons/slingshot/issues/3) by merging `and` optimizations from original PR [#55](https://github.com/scgilardi/slingshot/pull/55) by [jbouwman](https://github.com/jbouwman).
5+
36
* v0.13.0 -- 2025-09-20
47
- add clj-kondo config export
58
- move to clj-commons; rename nses to `clj-commons.*`

src/clj_commons/slingshot/support.clj

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,10 @@
140140
[(key-values []
141141
(and (vector? selector)
142142
(if (even? (count selector))
143-
`(and ~@(for [[key val] (partition 2 selector)]
144-
`(= (get ~'% ~key) ~val)))
143+
(if (= 2 (count selector))
144+
`(= (get ~'% ~(first selector)) ~(second selector))
145+
`(and ~@(for [[key val] (partition 2 selector)]
146+
`(= (get ~'% ~key) ~val))))
145147
(throw-arg "key-values selector: %s does not match: %s"
146148
(pr-str selector) "[key val & kvs]"))))
147149
(selector-form []

0 commit comments

Comments
 (0)