Common cases, text/html, text/xml and text/plain parse about 2x faster. Other
cases are about 30% faster.
Support quoted attributes, i.e. charset="utf-8" & valid escape sequences. This
potentially requires allocation, thus Mime.parse now takes an allocator.
Stricter validation around type/subtype based on RFC.
More tests.
Replace Mime.eql with isHTML(). Equality is complicated and was previously
incorrect (it was case sensitive, it should not be). Since we currently only
use isHTML-like behavior, built a (faster) method specifically for that.
Preserves all existing behavior (i.e. make test and zig build test are not
changed in any way).
The new 'unittest' only runs unit tests and is fast to build. It takes ~1.7 to
build unittest, vs ~11.09 to build test. This is really the main goal, and
hopefully any unit test which are (a) fast and (b) don't impact build times
will be run here.
The test runner is based on:
https://gist.github.com/karlseguin/c6bea5b35e4e8d26af6f81c22cb5d76b
It allow filtering, i.e. `make unittest F="parse query dup"`.
'unittest' does memory leak detection when tests use std.testing.allocator.
Fixed a memory leak in url/query which was detected/reported with by the new
'unittest'.
In order to avoid having 3 src/test_xyx.zig files, I merged the existing
test_runner.zig and run_tests.zig into a single main_tests.zig. (this change
is superfluous, but I thought it was cleaner this way. Happy to revert this).
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)
Leverage comptime fields to give generated Tuple a default value, allowing
TupleT and Tuple to be merged.
Only call generate.Tuple on the final output. This eliminates redundant
deduplication, and results in a simpler API (nested types just need to expose
a natural Zig tuple).
generate.Union leverages the new Tuple and removes unused features.