Improve performance & compliance of MIME parsing

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.
This commit is contained in:
Karl Seguin
2025-02-10 11:07:55 +08:00
parent 0c1a486ed9
commit 6863f3227f
4 changed files with 380 additions and 139 deletions

View File

@@ -35,7 +35,7 @@ pub const Reader = struct {
pub fn tail(self: *Reader) []const u8 {
const pos = self.pos;
const data = self.data;
if (pos > data.len) {
if (pos > data.len) {
return "";
}
self.pos = data.len;