fn tryParseDigits(comptime T: type, stream: *FloatStream, x: *T, comptime base: u8) void T: typestream: *FloatStreamx: *Tbase: u828
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47fn tryParseDigits(comptime T: type, stream: *FloatStream, x: *T, comptime base: u8) void {
// Try to parse 8 digits at a time, using an optimized algorithm.
// This only supports decimal digits.
if (base == 10) {
while (stream.hasLen(8)) {
const v = stream.readU64Unchecked();
if (!isEightDigits(v)) {
break;
}
x.* = x.* *% 1_0000_0000 +% parse8Digits(v);
stream.advance(8);
}
}
while (stream.scanDigit(base)) |digit| {
x.* *%= base;
x.* +%= digit;
}
}
Parse digits until a non-digit character is found.