Better inline of isDigit

This commit is contained in:
Jared Ramirez 2021-07-18 14:13:12 -07:00
parent 074aba0012
commit a763e046fc

View file

@ -62,8 +62,7 @@ pub const RocDec = extern struct {
continue; continue;
} }
// Is the char anything but digit? if (!isDigit(byte)) {
if ((byte -% 48) > 9) {
return null; return null;
} }
index += 1; index += 1;
@ -124,6 +123,10 @@ pub const RocDec = extern struct {
} }
} }
inline fn isDigit(c: u8) bool {
return (c -% 48) <= 9;
}
pub fn toStr(self: RocDec) ?RocStr { pub fn toStr(self: RocDec) ?RocStr {
// Special case // Special case
if (self.num == 0) { if (self.num == 0) {