anuraaga commented on a change in pull request #2587: Reduces array copying when converting uint64 to hex strings URL: https://github.com/apache/incubator-zipkin/pull/2587#discussion_r283126678
########## File path: zipkin/src/main/java/zipkin2/Span.java ########## @@ -659,18 +660,17 @@ public static String normalizeTraceId(String traceId) { } static String padLeft(String id, int desiredLength) { - StringBuilder builder = new StringBuilder(desiredLength); - int offset = desiredLength - id.length(); - - for (int i = 0; i < offset; i++) builder.append('0'); - builder.append(id); - return builder.toString(); + char[] data = Platform.get().idBuffer(); + int i = 0, length = id.length(), offset = desiredLength - length; + for (; i < offset; i++) data[i] = '0'; + for (int j = 0; j < length; j++) data[i++] = id.charAt(j); Review comment: `getChars` is probably a bit faster. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services