RFR (S) CR 8006627/8007398: Improve performance of Long.toUnsignedString0, Integer.toUnsignedString0, UUID(String) and UUID.toString

Ulf Zibis Ulf.Zibis at CoSoCo.de
Wed Feb 13 01:24:12 UTC 2013


Am 13.02.2013 00:30, schrieb Mike Duigou:
> Hi Steven;
>
> I have updated the patch for Java 8. There's somewhat less code sharing and a bit of refactoring than your last version but the performance should be about the same or a little better.
>
> http://cr.openjdk.java.net/~mduigou/JDK-8007398/0/webrev/

Couldn't you use String(buf, true) for all to(Unsigned)String(...) methods ?

Instead of calculating the mask each time, you could use:
  309     private static String toUnsignedString(int i, int shift, int mask) {

Additionally in e.g. Integer.toString(int i, int radix) you could provide the fast version with:
  134         /* Use the faster version */
  135         switch (radix) {
  136             case 2: return toString(i, 1, 0x1);
  136             case 4: return toString(i, 2, 0x3);
  136             case 8: return toString(i, 3, 0x7);
  136             case 10: return toString(i);
  136             case 16: return toString(i, 4, 0xF);
  136             case 32: return toString(i, 5, 0x1F);
  137         }


-Ulf





More information about the core-libs-dev mailing list