mirror of
https://github.com/junegunn/fzf.git
synced 2026-03-07 15:42:28 +08:00
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.
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user