You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zipkin.apache.org by GitBox <gi...@apache.org> on 2019/05/12 09:20:15 UTC

[GitHub] [incubator-zipkin] anuraaga commented on a change in pull request #2587: Reduces array copying when converting uint64 to hex strings

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_r283126284
 
 

 ##########
 File path: zipkin/src/main/java/zipkin2/Span.java
 ##########
 @@ -415,14 +416,14 @@ public Builder traceId(String traceId) {
      */
     public Builder traceId(long high, long low) {
       if (high == 0L && low == 0L) throw new IllegalArgumentException("empty trace ID");
-      char[] result = new char[high != 0L ? 32 : 16];
+      char[] data = Platform.get().idBuffer();
       int pos = 0;
       if (high != 0L) {
-        writeHexLong(result, pos, high);
+        writeHexLong(data, pos, high);
         pos += 16;
       }
-      writeHexLong(result, pos, low);
-      this.traceId = new String(result);
+      writeHexLong(data, pos, low);
+      this.traceId = new String(data, 0, high != 0L ? 32 : 16);
 
 Review comment:
   Think it might be worth the readability of extracting a `length` variable.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services