Swap should be better done native?

Ulf Zibis Ulf.Zibis at gmx.de
Thu Apr 1 17:28:03 PDT 2010


Am 01.04.2010 02:19, schrieb Martin Buchholz:
> On Wed, Mar 31, 2010 at 16:33, Ulf Zibis<Ulf.Zibis at gmx.de>  wrote:
>    
>> Am 01.04.2010 00:49, schrieb Martin Buchholz:
>>      
>> See for example:
>> class DirectByteBuffer
>>     ...
>>     private ByteBuffer putChar(long a, char x) {
>>         if (unaligned) {
>>             char y = (x);
>>             unsafe.putChar(a, (nativeByteOrder ? y : Bits.swap(y)));
>>         } else {
>>             Bits.putChar(a, x, bigEndian);
>>         }
>>         return this;
>>     }
>> 2.I'm not sure, when unaligned == false would occur.
>> We should consider, that unsafe.putChar(long, char) would become very fast
>> referring latest patch proposals.
>>      
> Why wouldn't it already be very fast?

I'm in the question if the !unaligned cases would always be faster than 
the unaligned cases in respect of the fast reverseBytes intrinsified 
methods.

-Ulf




More information about the nio-discuss mailing list