defer is slow and not worth it here
This commit is contained in:
parent
316c5ca6b1
commit
14862c2fc7
|
@ -190,9 +190,9 @@ func (serversInfo *ServersInfo) estimatorUpdate() {
|
||||||
|
|
||||||
func (serversInfo *ServersInfo) getOne() *ServerInfo {
|
func (serversInfo *ServersInfo) getOne() *ServerInfo {
|
||||||
serversInfo.Lock()
|
serversInfo.Lock()
|
||||||
defer serversInfo.Unlock()
|
|
||||||
serversCount := len(serversInfo.inner)
|
serversCount := len(serversInfo.inner)
|
||||||
if serversCount <= 0 {
|
if serversCount <= 0 {
|
||||||
|
serversInfo.Unlock()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if serversInfo.lbEstimator {
|
if serversInfo.lbEstimator {
|
||||||
|
@ -211,6 +211,7 @@ func (serversInfo *ServersInfo) getOne() *ServerInfo {
|
||||||
}
|
}
|
||||||
serverInfo := serversInfo.inner[candidate]
|
serverInfo := serversInfo.inner[candidate]
|
||||||
dlog.Debugf("Using candidate [%s] RTT: %d", (*serverInfo).Name, int((*serverInfo).rtt.Value()))
|
dlog.Debugf("Using candidate [%s] RTT: %d", (*serverInfo).Name, int((*serverInfo).rtt.Value()))
|
||||||
|
serversInfo.Unlock()
|
||||||
|
|
||||||
return serverInfo
|
return serverInfo
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue