diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2019-02-18 08:50:26 +0800 |
---|---|---|
committer | techknowlogick <matti@mdranta.net> | 2019-02-17 19:50:26 -0500 |
commit | a380cfd8e03148a05859a7496d235fa14bde4796 (patch) | |
tree | 9ef2f4b66804e73e242d0d07fd30769898a0ca23 /vendor/github.com/couchbase/vellum/registry.go | |
parent | 11e316654e523bd668a20e1e6a95da3f5b9b22de (diff) | |
download | gitea-a380cfd8e03148a05859a7496d235fa14bde4796.tar.gz gitea-a380cfd8e03148a05859a7496d235fa14bde4796.zip |
Update bleve dependency to latest master revision (#6100)
* update bleve to master b17287a86f6cac923a5d886e10618df994eeb54b6724eac2e3b8dde89cfbe3a2
* remove unused pkg from dep file
* change bleve from master to recent revision
Diffstat (limited to 'vendor/github.com/couchbase/vellum/registry.go')
-rw-r--r-- | vendor/github.com/couchbase/vellum/registry.go | 36 |
1 files changed, 17 insertions, 19 deletions
diff --git a/vendor/github.com/couchbase/vellum/registry.go b/vendor/github.com/couchbase/vellum/registry.go index 3721a7c9c3..f5b9b4d59c 100644 --- a/vendor/github.com/couchbase/vellum/registry.go +++ b/vendor/github.com/couchbase/vellum/registry.go @@ -14,39 +14,35 @@ package vellum -import ( - "hash" - "hash/fnv" -) - type registryCell struct { addr int node *builderNode } type registry struct { - table []registryCell - tableSize uint - mruSize uint - hasher hash.Hash64 + builderNodePool *builderNodePool + table []registryCell + tableSize uint + mruSize uint } -func newRegistry(tableSize, mruSize int) *registry { +func newRegistry(p *builderNodePool, tableSize, mruSize int) *registry { nsize := tableSize * mruSize rv := ®istry{ - table: make([]registryCell, nsize), - tableSize: uint(tableSize), - mruSize: uint(mruSize), - hasher: fnv.New64a(), + builderNodePool: p, + table: make([]registryCell, nsize), + tableSize: uint(tableSize), + mruSize: uint(mruSize), } return rv } func (r *registry) Reset() { - for i := 0; i < len(r.table); i++ { - r.table[i] = registryCell{} + var empty registryCell + for i := range r.table { + r.builderNodePool.Put(r.table[i].node) + r.table[i] = empty } - r.hasher.Reset() } func (r *registry) entry(node *builderNode) (bool, int, *registryCell) { @@ -57,7 +53,7 @@ func (r *registry) entry(node *builderNode) (bool, int, *registryCell) { start := r.mruSize * uint(bucket) end := start + r.mruSize rc := registryCache(r.table[start:end]) - return rc.entry(node) + return rc.entry(node, r.builderNodePool) } const fnvPrime = 1099511628211 @@ -81,11 +77,12 @@ func (r *registry) hash(b *builderNode) int { type registryCache []registryCell -func (r registryCache) entry(node *builderNode) (bool, int, *registryCell) { +func (r registryCache) entry(node *builderNode, pool *builderNodePool) (bool, int, *registryCell) { if len(r) == 1 { if r[0].node != nil && r[0].node.equiv(node) { return true, r[0].addr, nil } + pool.Put(r[0].node) r[0].node = node return false, 0, &r[0] } @@ -98,6 +95,7 @@ func (r registryCache) entry(node *builderNode) (bool, int, *registryCell) { } // no match last := len(r) - 1 + pool.Put(r[last].node) r[last].node = node // discard LRU r.promote(last) return false, 0, &r[0] |