Help with Type Hint

2009-05-14 Thread tmountain
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

Re: Help with Type Hint

2009-05-14 Thread David Nolen
If you're going to do that you're going to need to create a let binding which type-hints coll to bytes in your byte-array-contains? If you're going to be doing this a lot in your code I'd recommend making a helper class in Java. loop/recur is fast, but for absolute speed, you just can't beat

Re: Help with Type Hint

2009-05-14 Thread tmountain
Thanks for all the helpful advice. I may consider rewriting key portions in Java if performance becomes an issue. Travis On May 14, 12:10 pm, David Nolen dnolen.li...@gmail.com wrote: If you're going to do that you're going to need to create a let binding which type-hints coll to bytes in

Re: Help with Type Hint

2009-05-14 Thread Boris Mizhen - 迷阵
Please correct me if I'm wrong, but my understanding is that Clojure compiler can produce bytecode equivalent to compiled Java code. I think the right approach would be to figure out how to do this in Clojure for the cases like this. Rich? Boris On Thu, May 14, 2009 at 2:25 PM, tmountain

Re: Help with Type Hint

2009-05-14 Thread Dimiter malkia Stanev
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

Re: Help with Type Hint

2009-05-14 Thread Kevin Downey
so I took a look at with this code: http://gist.github.com/111935 output: :original Elapsed time: 369.683 msecs :redux-1 Elapsed time: 11672.329 msecs :redux-2 Elapsed time: 74.233 msecs as to why there is such a huge difference between your code and redux-2 I am not sure. I would definitely