Skip to content

Commit 98906be

Browse files
committed
parseData: remove iterator variant
1 parent 2207757 commit 98906be

File tree

1 file changed

+15
-24
lines changed

1 file changed

+15
-24
lines changed

src/browser/netsurf.zig

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2500,31 +2500,22 @@ fn parseParams(enc: ?[:0]const u8) c.dom_hubbub_parser_params {
25002500
}
25012501

25022502
fn parseData(parser: *c.dom_hubbub_parser, reader: anytype) !void {
2503-
var err: c.hubbub_error = undefined;
2504-
const TI = @typeInfo(@TypeOf(reader));
2505-
if (TI == .pointer and @hasDecl(TI.pointer.child, "next")) {
2506-
while (try reader.next()) |data| {
2507-
err = c.dom_hubbub_parser_parse_chunk(parser, data.ptr, data.len);
2508-
try parserErr(err);
2509-
}
2510-
} else {
2511-
var buffer: [1024]u8 = undefined;
2512-
var ln = buffer.len;
2513-
while (ln > 0) {
2514-
ln = try reader.read(&buffer);
2515-
err = c.dom_hubbub_parser_parse_chunk(parser, &buffer, ln);
2516-
// TODO handle encoding change error return.
2517-
// When the HTML contains a META tag with a different encoding than the
2518-
// original one, a c.DOM_HUBBUB_HUBBUB_ERR_ENCODINGCHANGE error is
2519-
// returned.
2520-
// In this case, we must restart the parsing with the new detected
2521-
// encoding. The detected encoding is stored in the document and we can
2522-
// get it with documentGetInputEncoding().
2523-
try parserErr(err);
2524-
}
2503+
var buffer: [1024]u8 = undefined;
2504+
var ln = buffer.len;
2505+
while (ln > 0) {
2506+
ln = try reader.read(&buffer);
2507+
const err = c.dom_hubbub_parser_parse_chunk(parser, &buffer, ln);
2508+
// TODO handle encoding change error return.
2509+
// When the HTML contains a META tag with a different encoding than the
2510+
// original one, a c.DOM_HUBBUB_HUBBUB_ERR_ENCODINGCHANGE error is
2511+
// returned.
2512+
// In this case, we must restart the parsing with the new detected
2513+
// encoding. The detected encoding is stored in the document and we can
2514+
// get it with documentGetInputEncoding().
2515+
try parserErr(err);
25252516
}
2526-
err = c.dom_hubbub_parser_completed(parser);
2527-
try parserErr(err);
2517+
const err = c.dom_hubbub_parser_completed(parser);
2518+
return parserErr(err);
25282519
}
25292520

25302521
// documentHTMLClose closes the document.

0 commit comments

Comments
 (0)