Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8042990

Optimize conversion to hex string

    Details

    • Type: Enhancement
    • Status: Closed
    • Priority: P5
    • Resolution: Won't Fix
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: core-libs
    • Labels:
      None

      Description

      jdk/src/share/classes/sun/security/smartcardio/PCSC.java

          private final static char[] hexDigits = "0123456789abcdef".toCharArray();

          public static String toString(byte[] b) {
              StringBuffer sb = new StringBuffer(b.length * 3);
              for (int i = 0; i < b.length; i++) {
                  int k = b[i] & 0xff;
                  if (i != 0) {
                      sb.append(':');
                  }
                  sb.append(hexDigits[k >>> 4]);
                  sb.append(hexDigits[k & 0xf]);
              }
              return sb.toString();
          }


      Can be replaced with

                  sb.append(Integer.toHexString(k >>> 4));
                  sb.append(Integer.toHexString(k & 0xf));

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                igerasim Ivan Gerasimov (Inactive)
                Reporter:
                igerasim Ivan Gerasimov (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: