Skip to content

Commit

Permalink
chore: Remove unnecessary return and judgement.
Browse files Browse the repository at this point in the history
  • Loading branch information
atlas-comstock committed Aug 29, 2020
1 parent d542f62 commit 7e4e7fd
Show file tree
Hide file tree
Showing 11 changed files with 8 additions and 23 deletions.
1 change: 0 additions & 1 deletion cluster/router/tag/tag_router.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@ func (c *tagRouter) Process(event *config_center.ConfigChangeEvent) {
defer c.mutex.Unlock()
c.tagRouterRule = routerRule
c.ruleChanged = true
return
}

// URL gets the url of tagRouter
Expand Down
2 changes: 1 addition & 1 deletion common/rpc_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ func (sm *serviceMap) UnRegister(interfaceName, protocol, serviceId string) erro
sm.mutex.Lock()
defer sm.mutex.Unlock()
sm.interfaceMap[interfaceName] = make([]*Service, 0, len(svrs))
for i, _ := range svrs {
for i := range svrs {
if i != index {
sm.interfaceMap[interfaceName] = append(sm.interfaceMap[interfaceName], svrs[i])
}
Expand Down
2 changes: 1 addition & 1 deletion common/url.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ func NewURL(urlString string, opts ...option) (URL, error) {
}

// rawUrlString = "//" + rawUrlString
if strings.Index(rawUrlString, "//") < 0 {
if !strings.Contains(rawUrlString, "//") {
t := URL{baseUrl: baseUrl{}}
for _, opt := range opts {
opt(&t)
Expand Down
16 changes: 3 additions & 13 deletions config/base_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,8 @@ func getKeyPrefix(val reflect.Value) []string {
} else {
prefix = val.MethodByName(configPrefixMethod).Call(nil)[0].String()
}
var retPrefixes []string

for _, pfx := range strings.Split(prefix, "|") {

retPrefixes = append(retPrefixes, pfx)

}
return retPrefixes

return strings.Split(prefix, "|")
}

func getPtrElement(v reflect.Value) reflect.Value {
Expand Down Expand Up @@ -216,12 +209,9 @@ func setFieldValue(val reflect.Value, id reflect.Value, config *config.InmemoryC
prefix := s.MethodByName("Prefix").Call(nil)[0].String()
for _, pfx := range strings.Split(prefix, "|") {
m := config.GetSubProperty(pfx)
if m != nil {
for k := range m {
f.SetMapIndex(reflect.ValueOf(k), reflect.New(f.Type().Elem().Elem()))
}
for k := range m {
f.SetMapIndex(reflect.ValueOf(k), reflect.New(f.Type().Elem().Elem()))
}

}

}
Expand Down
1 change: 0 additions & 1 deletion config/reference_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,5 +251,4 @@ func (c *ReferenceConfig) GenericLoad(id string) {
c.id = id
c.Refer(genericService)
c.Implement(genericService)
return
}
2 changes: 1 addition & 1 deletion config_center/configurator/override.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func (c *overrideConfigurator) configureIfMatchInternal(url *common.URL) {
func (c *overrideConfigurator) configureIfMatch(host string, url *common.URL) {
if constant.ANYHOST_VALUE == c.configuratorUrl.Ip || host == c.configuratorUrl.Ip {
providers := c.configuratorUrl.GetParam(constant.OVERRIDE_PROVIDERS_KEY, "")
if len(providers) == 0 || strings.Index(providers, url.Location) >= 0 || strings.Index(providers, constant.ANYHOST_VALUE) >= 0 {
if len(providers) == 0 || strings.Contains(providers, url.Location) || strings.Contains(providers, constant.ANYHOST_VALUE) {
c.configureIfMatchInternal(url)
}
}
Expand Down
1 change: 0 additions & 1 deletion protocol/rest/rest_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,4 @@ func (re *RestExporter) Unexport() {
if err != nil {
logger.Errorf("[RestExporter.Unexport] error: %v", err)
}
return
}
1 change: 0 additions & 1 deletion registry/etcdv3/listener_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ func (suite *RegistryTestSuite) SetupSuite() {
}

suite.etcd = e
return
}

// stop etcd server
Expand Down
2 changes: 1 addition & 1 deletion registry/event/service_revision_customizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func resolveRevision(urls []interface{}) string {

// append url params if we need it
}
sort.Sort(sort.StringSlice(candidates))
sort.Strings(candidates)

// it's nearly impossible to be overflow
res := uint64(0)
Expand Down
2 changes: 1 addition & 1 deletion registry/protocol/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func filterHideKey(url *common.URL) *common.URL {

// be careful params maps in url is map type
removeSet := gxset.NewSet()
for k, _ := range url.GetParams() {
for k := range url.GetParams() {
if strings.HasPrefix(k, ".") {
removeSet.Add(k)
}
Expand Down
1 change: 0 additions & 1 deletion remoting/zookeeper/curator_discovery/service_discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ func (sd *ServiceDiscovery) updateInternalService(name, id string) {
return
}
entry.instance = instance
return
}

// UnregisterService un-register service in zookeeper and delete service in cache
Expand Down

0 comments on commit 7e4e7fd

Please sign in to comment.