chore: fix lint issues from performance optimization
- errcheck: check type assertions from sync.Pool.Get() in loadbalance/balancer.go and matcher/radix.go - errcheck: check type assertion from list.Element.Value in resolver/resolver.go evictLRULocked - revive: add doc comment for exported ReleaseMatchResult function
This commit is contained in:
parent
7fe1ca6bec
commit
8e00e63972
@ -41,7 +41,8 @@ var filterContextPool = sync.Pool{
|
||||
}
|
||||
|
||||
func acquireFilterContext() *filterContext {
|
||||
return filterContextPool.Get().(*filterContext)
|
||||
fc, _ := filterContextPool.Get().(*filterContext)
|
||||
return fc
|
||||
}
|
||||
|
||||
func releaseFilterContext(fc *filterContext) {
|
||||
@ -633,5 +634,3 @@ func (t *Target) LastResolved() time.Time {
|
||||
}
|
||||
return time.Unix(0, nano)
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -229,7 +229,7 @@ func (t *RadixTree) FindLongestPrefix(path string) *MatchResult {
|
||||
if bestNode == nil {
|
||||
return nil
|
||||
}
|
||||
result := matchResultPool.Get().(*MatchResult)
|
||||
result, _ := matchResultPool.Get().(*MatchResult)
|
||||
result.Handler = bestNode.handler
|
||||
result.Path = bestNode.prefix
|
||||
result.Priority = bestNode.priority
|
||||
@ -271,6 +271,7 @@ func (t *RadixTree) searchLongest(node *RadixNode, path string, bestNode *RadixN
|
||||
return bestNode
|
||||
}
|
||||
|
||||
// ReleaseMatchResult 将 MatchResult 归还到对象池。
|
||||
func ReleaseMatchResult(r *MatchResult) {
|
||||
if r == nil {
|
||||
return
|
||||
|
||||
@ -83,7 +83,7 @@ func (r *DNSResolver) evictLRULocked() {
|
||||
if oldest == nil {
|
||||
return
|
||||
}
|
||||
host := oldest.Value.(string)
|
||||
host, _ := oldest.Value.(string)
|
||||
delete(r.cache, host)
|
||||
delete(r.lruIndex, host)
|
||||
r.lruList.Remove(oldest)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user