From b66850cc8c584cc00bcd796eb3aa238bcf87394a Mon Sep 17 00:00:00 2001 From: Lukasz Kasprzak Date: Thu, 17 Sep 2026 14:17:54 +0200 Subject: a file's name is folded once, not once per name test Folding is the expensive half of a name test on a name with diacritics, and every name test of every rule folded the same name again: on Polish names it was most of the matching work. The per-file facts memoise it, which is where one file's work belongs - the object is per file and per goroutine, so no lock. 4000 Polish names, twelve rules with name tests: 0.33s -> 0.13s --- internal/engine/engine_test.go | 2 ++ 1 file changed, 2 insertions(+) (limited to 'internal/engine/engine_test.go') diff --git a/internal/engine/engine_test.go b/internal/engine/engine_test.go index 89ea6f0..85679dc 100644 --- a/internal/engine/engine_test.go +++ b/internal/engine/engine_test.go @@ -12,6 +12,7 @@ import ( "git.labunix.xyz/krino/internal/cond" "git.labunix.xyz/krino/internal/config" + "git.labunix.xyz/krino/internal/norm" ) // sandbox gives a test its own HOME with no XDG overrides and returns it. @@ -55,6 +56,7 @@ func (f fakeFacts) Now() time.Time { return func (f fakeFacts) ContentContains(cond.Options, []string) (int, error) { return -1, nil } func (f fakeFacts) Duplicate([]string) (string, bool, error) { return "", false, nil } func (f fakeFacts) Matched() (bool, bool) { return false, false } +func (f fakeFacts) Folded(subj string) norm.Folded { return norm.FoldMapped(subj) } var _ cond.Facts = fakeFacts{} -- cgit v1.3