On Mon, 18 Sep 2023 13:40:48 GMT, Chen Liang <li...@openjdk.org> wrote:
>> In the improvement of @cl4es PR #15591, the advantages of non-lookup-table >> were discussed. >> >> But if the input is byte[], using lookup table can improve performance. >> >> For HexFormat#formatHex(Appendable, byte[]) and HexFormat#formatHex(byte[]), >> If the length of byte[] is larger, the performance of table lookup will be >> improved more obviously. > > src/java.base/share/classes/java/util/HexFormat.java line 422: > >> 420: toHexDigits(out, bytes[fromIndex + i]); >> 421: } >> 422: out.append(suffix); > > Maybe change this whole `else` block to > > for (int i = 0; i < length; i++) { > if (i > 0) > out.append(delimiter); > out.append(prefix); > toHexDigits(out, bytes[fromIndex + i]); > out.append(suffix); > } > > for clarity? The original (and current) is coded to avoid a condition inside the loop. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/15768#discussion_r1329167394