Skip to content

Commit f7d95b2

Browse files
authored
Polish code of buildFlowMap in flow/rule_manager.go (#131)
1 parent 76070e1 commit f7d95b2

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

core/flow/rule_manager.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ package flow
33
import (
44
"encoding/json"
55
"fmt"
6+
"sync"
7+
68
"github.com/alibaba/sentinel-golang/logging"
79
"github.com/pkg/errors"
8-
"sync"
910
)
1011

1112
// const
@@ -139,10 +140,11 @@ func getTrafficControllerListFor(name string) []*TrafficShapingController {
139140

140141
// NotThreadSafe (should be guarded by the lock)
141142
func buildFlowMap(rules []*FlowRule) TrafficControllerMap {
143+
m := make(TrafficControllerMap)
142144
if len(rules) == 0 {
143-
return make(TrafficControllerMap)
145+
return m
144146
}
145-
m := make(TrafficControllerMap)
147+
146148
for _, rule := range rules {
147149
if err := IsValidFlowRule(rule); err != nil {
148150
logger.Warnf("Ignoring invalid flow rule: %v, reason: %s", rule, err.Error())

0 commit comments

Comments
 (0)