Thank you, Konrad. Unrolling the bit-or computations helped; total
time for 8,000,000 iterations was 1305 msecs.

Per, you are correct. The byte issue (0xFF out of range) is why I have
to include the mask. I think this is more Java's limitation than
anything. 0xFF is not a valid value for a byte due to the JVM's broken
implementation of bytes. (My opinion, anyway.I think a byte should be
8 bits and I should be able to use all of them.)

On a more hideous note:

(defn arr-to-int [#^ints x]
  (bit-or
   (int (bit-or (int (bit-shift-left (int (bit-and (int 0x9F) (int
(aget x 0)))) 24)) ; don't want to overflow to long, hence 0x9F
                (int (bit-shift-left (int (bit-and (int 0xFF) (int
(aget x 1)))) 16))))
   (int (bit-or (int (bit-shift-left (int (bit-and (int 0xFF) (int
(aget x 2)))) 8))
                (int (bit-and (int 0xFF) (int (aget x 3))))))))


(time (dotimes [x 8000000] (arr-to-int tba)))

executes in 785 msecs. This is a substantial speedup over 4,736 msecs
(and even 1305 msecs).

Still not as good as native java, but you can't have everything. Thank
you, everyone, for the assistance!

Raph


-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
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

To unsubscribe from this group, send email to 
clojure+unsubscribegooglegroups.com or reply to this email with the words 
"REMOVE ME" as the subject.

Reply via email to