mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
isHex, isAlphanumeric: prong reorder
On x86 interestingly I can see a reduction in codesize by 1 instruction with this. While not necessarily faster, it might still reduce codesize a bit and this ordering is also more logical because it follows ASCII table order. Rust's std uses this ordering too. See https://zig.godbolt.org/z/PqodY8YqY for the difference.
This commit is contained in:
parent
19dbc5805c
commit
0162a0868c
1 changed files with 2 additions and 2 deletions
|
|
@ -91,7 +91,7 @@ pub const control_code = struct {
|
||||||
/// Returns whether the character is alphanumeric: A-Z, a-z, or 0-9.
|
/// Returns whether the character is alphanumeric: A-Z, a-z, or 0-9.
|
||||||
pub fn isAlphanumeric(c: u8) bool {
|
pub fn isAlphanumeric(c: u8) bool {
|
||||||
return switch (c) {
|
return switch (c) {
|
||||||
'A'...'Z', 'a'...'z', '0'...'9' => true,
|
'0'...'9', 'A'...'Z', 'a'...'z' => true,
|
||||||
else => false,
|
else => false,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -167,7 +167,7 @@ pub fn isUpper(c: u8) bool {
|
||||||
/// Returns whether the character is a hexadecimal digit: A-F, a-f, or 0-9.
|
/// Returns whether the character is a hexadecimal digit: A-F, a-f, or 0-9.
|
||||||
pub fn isHex(c: u8) bool {
|
pub fn isHex(c: u8) bool {
|
||||||
return switch (c) {
|
return switch (c) {
|
||||||
'A'...'F', 'a'...'f', '0'...'9' => true,
|
'0'...'9', 'A'...'F', 'a'...'f' => true,
|
||||||
else => false,
|
else => false,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue