zipkin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [incubator-zipkin] adriancole commented on a change in pull request #2582: Reuse char[] buffer when decoding hex fields.
Date Sat, 11 May 2019 06:58:17 GMT
adriancole commented on a change in pull request #2582: Reuse char[] buffer when decoding hex
fields.
URL: https://github.com/apache/incubator-zipkin/pull/2582#discussion_r283085221
 
 

 ##########
 File path: zipkin/src/main/java/zipkin2/internal/Proto3Fields.java
 ##########
 @@ -164,6 +164,13 @@ final int readLengthPrefix(Buffer b) {
     static final char[] HEX_DIGITS =
       {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
 
+    // Reuse the buffer for decoding into hex since it's immediately copied into a String.
+    static final ThreadLocal<char[]> THIRTY_TWO_CHARS = new ThreadLocal<char[]>()
{
 
 Review comment:
   Sorry for not remembering the specific nuance, but I recall us doing something like this
vs using an anonymous subclass in brave. If same to you, mind following that vs us hunting
down the conversations around it?
   
   ```java
     static final ThreadLocal<char[]> CHAR_BUFFER = new ThreadLocal<>();
   
     static char[] getCharBuffer() {
       char[] charBuffer = CHAR_BUFFER.get();
       if (charBuffer == null) {
         charBuffer = new char[FORMAT_MAX_LENGTH];
         CHAR_BUFFER.set(charBuffer);
       }
       return charBuffer;
     }
   ```

----------------------------------------------------------------
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

Mime
View raw message