This is the best I was able to come up with in Clojure:

(defn byte-array-contains? [coll key]
  "scans a byte array for a given value"
  (let [c (int (count coll))
        k (byte key)]
    (loop [i (int 0)]
      (if (< i c)
        (if (= k (aget coll i))
          true
          (recur (unchecked-inc i)))))))


On May 14, 8:22 am, tmountain <tinymount...@gmail.com> wrote:
> I'm trying to optimize some code I've written, and I have set warn on
> reflection as advised. I'm having a hard time getting a simple
> statement to avoid reflection.
>
> user=> (== (byte 0x1) (byte 0x1))
> Reflection warning, line: 33 - call to equiv can't be resolved.
>
> Can you use type hints on primitive types? I've tried obvious stuff
> like:
>
> user=> (== #^byte (byte 0x1) #^byte (byte 0x1))
> Reflection warning, line: 4 - call to equiv can't be resolved.
>
> and other variations without success.
>
> Thanks,
> Travis
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to