Unsafe.{get,put}-X-Unaligned; Efficient array comparison intrinsics

Andrew Haley aph at redhat.com
Thu Mar 5 08:45:45 UTC 2015


On 05/03/15 01:01, David Holmes wrote:
> I'm only glancing at parts of this ...
> 
> On 5/03/2015 6:21 AM, Andrew Haley wrote:
>> John's suggestion works well; the code is smaller and neater.
>>
>> http://cr.openjdk.java.net/~aph/unaligned.jdk.3/
> 
> This doesn't make sense to me:
> 
>   929     // The byte ordering of this machine
>   930     public final static boolean LITTLE_ENDIAN = false;
>   931     public final static boolean BIG_ENDIAN = true;
> 
> as they won't necessarily represent "this" machine! And the usage:
> 
> !     private static final ByteOrder byteOrder
> !         = unsafe.getByteOrder() == Unsafe.LITTLE_ENDIAN ? 
> ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN;
> 
> suggests getByteorder() is really isBigEndian() (which the hotspot part 
> confirms) - so then the two constants can be removed completely:
> 
> private static final ByteOrder byteOrder
>      = unsafe.isBigEndian() ? ByteOrder.BIG_ENDIAN : 
> ByteOrder.LITTLE_ENDIAN;

Indeed, I was thinking of giving that method a better name.  Works for me.

Andrew.





More information about the core-libs-dev mailing list