perf: Fix minor perf issue for JS

This commit is contained in:
2025-09-22 12:30:09 +01:00
parent a00af69b56
commit 3cd6d5d4af
2 changed files with 22 additions and 17 deletions

View File

@@ -374,10 +374,11 @@ pub fn parse_hex_digit(str: String) -> Result(#(String, String), Nil) {
case string.pop_grapheme(str) {
Ok(#(char, tail)) -> {
let assert [codepoint] = string.to_utf_codepoints(char)
case string.utf_codepoint_to_int(codepoint) {
i if i >= 0x30 && i <= 0x39 -> Ok(#(char, tail))
i if i >= 0x41 && i <= 0x46 -> Ok(#(char, tail))
i if i >= 0x61 && i <= 0x66 -> Ok(#(char, tail))
let i = string.utf_codepoint_to_int(codepoint)
case i {
_ if i >= 0x30 && i <= 0x39 -> Ok(#(char, tail))
_ if i >= 0x41 && i <= 0x46 -> Ok(#(char, tail))
_ if i >= 0x61 && i <= 0x66 -> Ok(#(char, tail))
_ -> Error(Nil)
}
}