From 46ee28ce7fa59af4e67eee55b241d51af15cef4b Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Fri, 16 Oct 2026 06:29:21 -1000 Subject: Trim avatar addresses in linear time The trim pattern backtracked over a run of spaces inside an address, which a commit can carry, and a log page runs the filter for every row. Forty thousand spaces took two seconds per row. --- tests/extensions/test-email-avatar.lua | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'tests/extensions/test-email-avatar.lua') diff --git a/tests/extensions/test-email-avatar.lua b/tests/extensions/test-email-avatar.lua index 94fec7e..4960ec3 100644 --- a/tests/extensions/test-email-avatar.lua +++ b/tests/extensions/test-email-avatar.lua @@ -68,6 +68,12 @@ h.equals("empty angle brackets draw no icon", out, "A U Thor") out = h.run({ "", "commit" }, { "A U ", "Thor" }) h.contains("the name is buffered across writes", out, "> A U Thor") +-- A commit can carry any bytes in its address, and a log page runs the +-- filter once per row, so the trim has to stay linear in a run of spaces. +local started = os.clock() +render("", "x") +h.check("a long run of inner spaces is trimmed quickly", os.clock() - started < 0.5) + if mode == "real" then out = render("test@example.com", "x") h.equals("a known address hashes to its published md5", hash_of(out), "55502f40dc8b7c769880b10874abc9d0") -- cgit