Description
Both `src/xml.zig` and `src/json.zig` read stdin byte-by-byte using `takeByte()` in a tight loop before parsing:
```zig
while (true) {
const byte = reader.takeByte() catch |err| switch (err) {
error.EndOfStream => break,
error.ReadFailed => fatal(...),
};
buf.append(allocator, byte) catch fatal(...);
}
```
This calls the reader dispatch logic once per byte. For a 10 MB file that is ~10 M iterations instead of ~2 500 with 4 KB block reads. For typical sql-pipe inputs (KBs to a few MBs piped from other processes) the overhead is unnoticeable, but it scales poorly for large files.
The pattern appears in 3 functions in `xml.zig` (`loadXmlInput`, `getXmlColumnNames`, `summarizeXml`) and in `json.zig`.
Acceptance Criteria
Notes
Check the `std.Io.Reader` API available in Zig 0.16 for the appropriate bulk-read method before implementing.
Description
Both `src/xml.zig` and `src/json.zig` read stdin byte-by-byte using `takeByte()` in a tight loop before parsing:
```zig
while (true) {
const byte = reader.takeByte() catch |err| switch (err) {
error.EndOfStream => break,
error.ReadFailed => fatal(...),
};
buf.append(allocator, byte) catch fatal(...);
}
```
This calls the reader dispatch logic once per byte. For a 10 MB file that is ~10 M iterations instead of ~2 500 with 4 KB block reads. For typical sql-pipe inputs (KBs to a few MBs piped from other processes) the overhead is unnoticeable, but it scales poorly for large files.
The pattern appears in 3 functions in `xml.zig` (`loadXmlInput`, `getXmlColumnNames`, `summarizeXml`) and in `json.zig`.
Acceptance Criteria
Notes
Check the `std.Io.Reader` API available in Zig 0.16 for the appropriate bulk-read method before implementing.