diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
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.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/extensions/test-email-avatar.lua | 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
1 file changed, 6 insertions, 0 deletions
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({ "<author@example.com>", "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("<a" .. string.rep(" ", 40000) .. "b>", "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") |
