Skip to content
Snippets Groups Projects
Commit a82ee383 authored by 邹毅贤's avatar 邹毅贤
Browse files

fix review comment

parent dc7e5d08
No related branches found
No related tags found
No related merge requests found
......@@ -18,6 +18,7 @@
package chain
import (
"math"
"sort"
"sync"
)
......@@ -51,7 +52,7 @@ type RouterChain struct {
func (c RouterChain) Route(invoker []protocol.Invoker, url *common.URL, invocation protocol.Invocation) []protocol.Invoker {
finalInvokers := invoker
l := len(c.routers)
rs := make([]router.Router, l, l)
rs := make([]router.Router, l, math.Ceil(float64(l)*1.2))
c.mutex.RLock()
copy(rs, c.routers)
c.mutex.RUnlock()
......
......@@ -90,7 +90,9 @@ func (l *listenableRouter) Process(event *config_center.ConfigChangeEvent) {
logger.Infof("Notification of condition rule, change type is:[%s] , raw rule is:[%v]", event.ConfigType, event.Value)
if remoting.EventTypeDel == event.ConfigType {
l.routerRule = nil
l.conditionRouters = make([]*ConditionRouter, 0)
if l.conditionRouters != nil {
l.conditionRouters = l.conditionRouters[:0]
}
return
}
content, ok := event.Value.(string)
......@@ -112,7 +114,7 @@ func (l *listenableRouter) generateConditions(rule *RouterRule) {
if rule == nil || !rule.Valid {
return
}
l.conditionRouters = make([]*ConditionRouter, 0)
l.conditionRouters = make([]*ConditionRouter, 0, len(rule.Conditions))
l.routerRule = rule
for _, c := range rule.Conditions {
router, e := NewConditionRouterWithRule(c)
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment