summaryrefslogtreecommitdiff
path: root/src/p4.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-08-25 21:42:56 -0300
committerGabriel Schneider <[email protected]>2026-08-25 21:42:56 -0300
commit209b48a36db527904ddc4b436f79df45cea3ab3e (patch)
treea9ebb993b56ea658fed74b308156c50e247ab48b /src/p4.zig
parent81c149b4343c125051c829bac13eea0c38f4262c (diff)
downloadpardes-209b48a36db527904ddc4b436f79df45cea3ab3e.tar.gz
pardes-209b48a36db527904ddc4b436f79df45cea3ab3e.zip
Drop the dead std.fmt fallback in the emitter's integer writer
Five digits is every u16, so the `v >= 10000` branch could never be taken and it was dragging `std.fmt.printInt` into a firmware whose whole reason for hand-rolling this was to keep the format machinery out of the hottest sequence it emits. Behaviour is identical, and re-verified rather than assumed: screen byte-identical to the vaxis reference on the 18-step workload, round trip median 3830 us over 60 trials (3829 before), snap 95/95, hxdiff 481/0, hxparity 561/0, unit-test.
Diffstat (limited to 'src/p4.zig')
-rw-r--r--src/p4.zig3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/p4.zig b/src/p4.zig
index 0f23ddd5..5319ad90 100644
--- a/src/p4.zig
+++ b/src/p4.zig
@@ -722,8 +722,9 @@ fn cup(row: u16, col: u16) !void {
try emitRaw(b[0..i]);
}
+/// Decimal, least significant digit first into a scratch buffer and then reversed. Five digits is
+/// every `u16`, so there is no fallback to `std.fmt` and no value this cannot write.
fn dec(buf: []u8, v: u16) usize {
- if (v >= 10000) return std.fmt.printInt(buf, v, 10, .lower, .{});
var digits: [5]u8 = undefined;
var n: usize = 0;
var rest = v;