You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@zookeeper.apache.org by GitBox <gi...@apache.org> on 2022/09/02 10:59:32 UTC

[GitHub] [zookeeper] maoling commented on a diff in pull request #1910: ZOOKEEPER-4600: Using more efficient method to format byte array to hex string

maoling commented on code in PR #1910:
URL: https://github.com/apache/zookeeper/pull/1910#discussion_r961556050


##########
zookeeper-server/src/main/java/org/apache/zookeeper/server/FinalRequestProcessor.java:
##########
@@ -588,9 +589,7 @@ public void processRequest(Request request) {
             StringBuilder sb = new StringBuilder();
             byte[] payload = request.readRequestBytes();
             if (payload != null) {
-                for (byte b : payload) {
-                    sb.append(String.format("%02x", (0xff & b)));
-                }
+                HexUtil.encodeHex(payload, sb);

Review Comment:
   - It could not be better if you can use the `JMH` framework to test this new method comparing to the old one, convincing us the new one is more efficient.
   - BTW, `PrepRequestProcessor` also has this code snippet



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

To unsubscribe, e-mail: notifications-unsubscribe@zookeeper.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org