hg: jdk7/tl/jdk: 6642323: Speeding up Single Byte Decoders; ...

Ulf Zibis Ulf.Zibis at gmx.de
Mon Dec 15 13:08:50 PST 2008


Maybe:
          for (int sl = sp + (sr <= dr ? sr : dr); sp != sl; sp++, dp++)
is little more faster than:
          for (int sl = sp + (sr <= dr ? sr : dr); sp < sl; sp++, dp++)

-Ulf


Am 15.12.2008 21:56, Ulf Zibis schrieb:
> Maybe little faster, especially for short strings:
>
>       private CoderResult decodeArrayLoop(ByteBuffer src, CharBuffer 
> dst) {
>           byte[] sa = src.array();
>           int sp = src.arrayOffset() + src.position();
>           int sr = src.remaining();  // faster than ... 
> src.arrayOffset() + src.limit()
>
>           char[] da = dst.array();
>           int dp = dst.arrayOffset() + dst.position();
>           int dr = dst.remaining(); // dl is never used
>
>           for (int sl = sp + (sr <= dr ? sr : dr); sp < sl; sp++, dp++)
>               if ((da[dp] = decode(sa[sp])) == UNMAPPABLE_DECODING)
>                   return 
> withResult(CoderResult.unmappableForLength(1), src, sp, dst, dp);
>           return withResult(sr <= dr ? CoderResult.UNDERFLOW : 
> CoderResult.OVERFLOW, src, sp, dst, dp);
>       }
>
> Regards,
> Ulf
>




More information about the serviceability-dev mailing list