Skip to content

Commit

Permalink
android: perf: speed up bytesToHex
Browse files Browse the repository at this point in the history
  • Loading branch information
chipweinberger committed Jul 23, 2024
1 parent 51d3d24 commit b3fb846
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2721,9 +2721,10 @@ private static String bytesToHex(byte[] bytes) {
if (bytes == null) {
return "";
}
StringBuilder sb = new StringBuilder();
StringBuilder sb = new StringBuilder(bytes.length * 2);
for (byte b : bytes) {
sb.append(String.format("%02x", b));
sb.append(Character.forDigit((b >> 4) & 0xF, 16));
sb.append(Character.forDigit(b & 0xF, 16));
}
return sb.toString();
}
Expand Down

0 comments on commit b3fb846

Please sign in to comment.