Skip to content

Commit 88fb317

Browse files
authored
Limit init valid hex array to range that can be true (#7809)
1 parent 18f8a13 commit 88fb317

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

api/all/src/main/java/io/opentelemetry/api/internal/OtelEncodingUtils.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,11 @@ private static byte[] buildDecodingArray() {
4444

4545
private static boolean[] buildValidHexArray() {
4646
boolean[] validHex = new boolean[Character.MAX_VALUE];
47-
for (int i = 0; i < Character.MAX_VALUE; i++) {
48-
validHex[i] = (48 <= i && i <= 57) || (97 <= i && i <= 102);
47+
// Use the fact that the default initial boolean value is false
48+
// and only explicitly init the values between the extreme HEX values
49+
// This minimized impact during process startup esp. on mobile.
50+
for (int i = 48; i < 103; i++) {
51+
validHex[i] = i <= 57 || 97 <= i;
4952
}
5053
return validHex;
5154
}

0 commit comments

Comments
 (0)