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/cond/eval_test.go | 3 +++ 1 file changed, 3 insertions(+) (limited to 'internal/cond/eval_test.go') diff --git a/internal/cond/eval_test.go b/internal/cond/eval_test.go index 5074557..7f06afd 100644 --- a/internal/cond/eval_test.go +++ b/internal/cond/eval_test.go @@ -39,6 +39,9 @@ func (f *fake) Size() int64 { return f.size } func (f *fake) ModTime() time.Time { return now.Add(-f.age) } func (f *fake) Now() time.Time { return now } func (f *fake) Matched() (bool, bool) { return f.matched, f.matchedUnknown } + +// Folded has no memo here: a fake stands in for one file in one test. +func (f *fake) Folded(subj string) norm.Folded { return norm.FoldMapped(subj) } func (f *fake) ContentContains(opt Options, keywords []string) (int, error) { f.contentCalls++ if f.rawErr != nil { -- cgit v1.3