zipkin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [incubator-zipkin] anuraaga commented on a change in pull request #2588: Consolidates buffers and generally improves string decoding
Date Sun, 12 May 2019 09:29:13 GMT
anuraaga commented on a change in pull request #2588: Consolidates buffers and generally improves
string decoding
URL: https://github.com/apache/incubator-zipkin/pull/2588#discussion_r283128048
 
 

 ##########
 File path: zipkin/src/main/java/zipkin2/internal/UnsafeBuffer.java
 ##########
 @@ -98,19 +98,33 @@ public void reset() {
 
   String readUtf8(int length) {
     require(length);
-    String result = new String(buf, pos, length, UTF_8);
+    String result = maybeDecodeShortAsciiString(buf, pos, length);
+    if (result == null) result = new String(buf, pos, length, UTF_8);
     pos += length;
     return result;
   }
 
+  // Speculatively assume all 7-bit ASCII characters.. common in normal tags and names
+  @Nullable static String maybeDecodeShortAsciiString(byte[] buf, int offset, int length)
{
 
 Review comment:
   Did you happen to target this method specifically in the microbench? the `String(byte[],
UTF_8)` constructor special-cases ASCII strings, similar to this code, and it might be even
faster on JVM9+ where ascii byte arrays use `System.arrayCopy` without converting to chars
at all. 

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