From 0c6ead6e9809b4eadfdc4840c758d8c3e9a012ac Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Sat, 7 Mar 2026 14:19:05 +0900 Subject: [PATCH] Replace procFun map with fixed-size array for faster algo dispatch termType is already a small integer enum (0-5), so a [6]algo.Algo array avoids hash table overhead in the extendedMatch hot loop. --- src/pattern.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pattern.go b/src/pattern.go index 94201bd4..b4a1898e 100644 --- a/src/pattern.go +++ b/src/pattern.go @@ -61,7 +61,7 @@ type Pattern struct { delimiter Delimiter nth []Range revision revision - procFun map[termType]algo.Algo + procFun [6]algo.Algo cache *ChunkCache denylist map[int32]struct{} startIndex int32 @@ -150,7 +150,7 @@ func BuildPattern(cache *ChunkCache, patternCache map[string]*Pattern, fuzzy boo cache: cache, denylist: denylist, startIndex: startIndex, - procFun: make(map[termType]algo.Algo)} + } ptr.cacheKey = ptr.buildCacheKey() ptr.directAlgo, ptr.directTerm = ptr.buildDirectAlgo(fuzzyAlgo)