Skip to content
Snippets Groups Projects
Commit 04123ad5 authored by YongHaoHu's avatar YongHaoHu
Browse files

chore: Remove unnecessary return and judgement.

parent f5dffb37
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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])
}
......
......@@ -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)
......
......@@ -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 {
......@@ -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()))
}
}
}
......
......@@ -251,5 +251,4 @@ func (c *ReferenceConfig) GenericLoad(id string) {
c.id = id
c.Refer(genericService)
c.Implement(genericService)
return
}
......@@ -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)
}
}
......
......@@ -49,5 +49,4 @@ func (re *RestExporter) Unexport() {
if err != nil {
logger.Errorf("[RestExporter.Unexport] error: %v", err)
}
return
}
......@@ -63,7 +63,6 @@ func (suite *RegistryTestSuite) SetupSuite() {
}
suite.etcd = e
return
}
// stop etcd server
......
......@@ -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)
......
......@@ -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)
}
......
......@@ -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
......
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