30% Faster isHex for strings with 64 bytes.

This commit is contained in:
Vitor Pamplona
2025-10-03 15:58:01 -04:00
parent 21c1d705a1
commit 7994945209
3 changed files with 133 additions and 19 deletions

View File

@@ -100,17 +100,7 @@ class HexBenchmark {
}
@Test
fun newIsHex() {
val isHexChar =
BooleanArray(256).apply {
"0123456789abcdefABCDEF".forEach { this[it.code] = true }
}
r.measureRepeated {
for (c in hex.indices) {
if (!isHexChar[hex[c].code]) return@measureRepeated
}
return@measureRepeated
}
fun isHex64() {
r.measureRepeated { Hex.isHex64(hex) }
}
}