diff options
Diffstat (limited to 'src/cache.go')
| -rw-r--r-- | src/cache.go | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/cache.go b/src/cache.go index f2f84a0a..d2ec00b4 100644 --- a/src/cache.go +++ b/src/cache.go @@ -2,23 +2,23 @@ package fzf import "sync" -// QueryCache associates strings to lists of items -type QueryCache map[string][]*Item +// queryCache associates strings to lists of items +type queryCache map[string][]*Item // ChunkCache associates Chunk and query string to lists of items type ChunkCache struct { mutex sync.Mutex - cache map[*Chunk]*QueryCache + cache map[*Chunk]*queryCache } // NewChunkCache returns a new ChunkCache func NewChunkCache() ChunkCache { - return ChunkCache{sync.Mutex{}, make(map[*Chunk]*QueryCache)} + return ChunkCache{sync.Mutex{}, make(map[*Chunk]*queryCache)} } // Add adds the list to the cache func (cc *ChunkCache) Add(chunk *Chunk, key string, list []*Item) { - if len(key) == 0 || !chunk.IsFull() { + if len(key) == 0 || !chunk.IsFull() || len(list) > queryCacheMax { return } @@ -27,7 +27,7 @@ func (cc *ChunkCache) Add(chunk *Chunk, key string, list []*Item) { qc, ok := cc.cache[chunk] if !ok { - cc.cache[chunk] = &QueryCache{} + cc.cache[chunk] = &queryCache{} qc = cc.cache[chunk] } (*qc)[key] = list |
