Skip to content

Commit

Permalink
Slightly fster array population
Browse files Browse the repository at this point in the history
Signed-off-by: Shay Gordon <[email protected]>
  • Loading branch information
camembertelectrique committed Jun 22, 2020
1 parent 9bdfdf0 commit 8bddea9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions utils/src/main/java/org/web3j/utils/Numeric.java
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,10 @@ public static String toHexString(byte[] input, int offset, int length, boolean w

public static char[] toHexCharArray(byte[] input, int offset, int length, boolean withPrefix) {
final char[] output = new char[length << 1];
for (int i = offset; i < length; i++) {
for (int i = offset, j = 0; i < length; i++, j++) {
final int v = input[i] & 0xFF;
output[i * 2] = HEX_CHAR_MAP[v >>> 4];
output[i * 2 + 1] = HEX_CHAR_MAP[v & 0x0F];
output[j++] = HEX_CHAR_MAP[v >>> 4];
output[j] = HEX_CHAR_MAP[v & 0x0F];
}
return output;
}
Expand Down

0 comments on commit 8bddea9

Please sign in to comment.