milestone 18: collapse duplicated infrastructure into shared listener core, crud list helper, resource shells, transport race, name and line helpers, ui modules
This commit is contained in:
+5
-13
@@ -1530,20 +1530,12 @@ fn destroySnapshot(gpa: Allocator, snapshot: *matcher.Snapshot) void {
|
||||
fn collectSample(r: *std.Io.Reader, w: *std.Io.Writer) error{ ReadFailed, WriteFailed }!void {
|
||||
var considered: usize = 0;
|
||||
while (considered < parsers.sample_lines) {
|
||||
const raw = r.takeDelimiter('\n') catch |err| switch (err) {
|
||||
// The stream is left unmodified here, so the line has to be stepped
|
||||
// over or this loop never advances.
|
||||
error.StreamTooLong => {
|
||||
_ = r.discardDelimiterInclusive('\n') catch |discard_err| switch (discard_err) {
|
||||
error.EndOfStream => return,
|
||||
error.ReadFailed => return error.ReadFailed,
|
||||
};
|
||||
continue;
|
||||
},
|
||||
error.ReadFailed => return error.ReadFailed,
|
||||
} orelse return;
|
||||
const event = (try parsers.nextBoundedLine(r, compiler.max_line_len)) orelse return;
|
||||
const raw = switch (event) {
|
||||
.long_line => continue,
|
||||
.line => |line| line,
|
||||
};
|
||||
|
||||
if (raw.len > compiler.max_line_len) continue;
|
||||
const line = std.mem.trim(u8, raw, &std.ascii.whitespace);
|
||||
if (line.len == 0) continue;
|
||||
if (parsers.isComment(line)) continue;
|
||||
|
||||
Reference in New Issue
Block a user