Minor Reader tweaks

1- Remove `parser.trim`, it was only being used in 1 place. All other places
   are using `std.mem.trim(u8, X, &std.ascii.whitespace)`, so i updated MIME to
   use this as well

2- Use slightly more meaningful field name, i => pos, s = data

3- Leverage std.mem.indexOfScalarPos which can be more efficient for longer
   inputs (since it leverages SIMD)
This commit is contained in:
Karl Seguin
2025-02-08 15:54:40 +08:00
parent 1594f148f8
commit 688cb55c2b
3 changed files with 45 additions and 62 deletions

View File

@@ -199,12 +199,12 @@ pub fn parseQuery(alloc: std.mem.Allocator, s: []const u8) !Values {
const ln = s.len;
if (ln == 0) return values;
var r = Reader{ .s = s };
var r = Reader{ .data = s };
while (true) {
const param = r.until('&');
if (param.len == 0) break;
var rr = Reader{ .s = param };
var rr = Reader{ .data = param };
const k = rr.until('=');
if (k.len == 0) continue;