mirror of
https://github.com/junegunn/fzf.git
synced 2026-08-14 03:41:07 +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:
+2
-2
@@ -61,7 +61,7 @@ type Pattern struct {
|
|||||||
delimiter Delimiter
|
delimiter Delimiter
|
||||||
nth []Range
|
nth []Range
|
||||||
revision revision
|
revision revision
|
||||||
procFun map[termType]algo.Algo
|
procFun [6]algo.Algo
|
||||||
cache *ChunkCache
|
cache *ChunkCache
|
||||||
denylist map[int32]struct{}
|
denylist map[int32]struct{}
|
||||||
startIndex int32
|
startIndex int32
|
||||||
@@ -150,7 +150,7 @@ func BuildPattern(cache *ChunkCache, patternCache map[string]*Pattern, fuzzy boo
|
|||||||
cache: cache,
|
cache: cache,
|
||||||
denylist: denylist,
|
denylist: denylist,
|
||||||
startIndex: startIndex,
|
startIndex: startIndex,
|
||||||
procFun: make(map[termType]algo.Algo)}
|
}
|
||||||
|
|
||||||
ptr.cacheKey = ptr.buildCacheKey()
|
ptr.cacheKey = ptr.buildCacheKey()
|
||||||
ptr.directAlgo, ptr.directTerm = ptr.buildDirectAlgo(fuzzyAlgo)
|
ptr.directAlgo, ptr.directTerm = ptr.buildDirectAlgo(fuzzyAlgo)
|
||||||
|
|||||||
Reference in New Issue
Block a user