> An interesting founding is that it seems typecasting from short to int
> and asetting to an int-array is 3-4 times faster than typecasting from
> int to short and asetting to an short array.

Thought: Java primitive types, when manipulated individually, are all  
"secretly ints" — there is no real unsigned int, short, byte, etc.  
type in Java.

The only time those declarations matter are:

* For range checking/documentation
* In arrays, where the JVM will pack values to save space.

You could only know for sure what's happening by inspecting the  
bytecode and JITted assembly, but I suspect that ints are faster for  
one reason: when you're dealing with shifting free shorts between  
variables and arrays, you're dealing with a representation change.

With an int, a 32-bit store is all that's needed for array setting.  
For shorts you need a fetch a segment of the array into a 32-bit  
register, use bitwise operations against that segment and your  
"short" (stored in 32 bits!) to set the appropriate part of those 32  
bits, and a store back to the array.

When you're treating that short as an int, your simply setting a 32- 
bit region of the array.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to