Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance warning - case has int tests, but tested expression is not primitive. #72

Open
ggeoffrey opened this issue Nov 5, 2022 · 0 comments

Comments

@ggeoffrey
Copy link
Collaborator

This warning shows up when *warn-on-reflection* is set to true.

It comes from amb:

(defmacro
  ^{:arglists '([& forms])
    :doc "In an `ap` block, evaluates each form sequentially and returns successive results."}
  amb
  ([] `(?> none))
  ([form] form)
  ([form & forms]
   (let [n (inc (count forms))]
     `(case (?> (seed (range ~n)))                          ; <- missing `int` cast
        ~@(interleave (range) (cons form forms))))))

(case (int (?> (seed (range ~n)))) …) fixes the issue

The same applies to amb=.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant