mirror of
https://github.com/golang/go
synced 2024-11-12 10:20:27 -07:00
net: simplify nested if-blocks
Change-Id: I32e1829c955a48d8c4566430c13679e237bb0611 Reviewed-on: https://go-review.googlesource.com/c/148337 Run-TryBot: Mikio Hara <mikioh.public.networking@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
05a85f493c
commit
7da1f7addf
@ -223,15 +223,13 @@ func (zc *ipv6ZoneCache) name(index int) string {
|
|||||||
zoneCache.RLock()
|
zoneCache.RLock()
|
||||||
name, ok := zoneCache.toName[index]
|
name, ok := zoneCache.toName[index]
|
||||||
zoneCache.RUnlock()
|
zoneCache.RUnlock()
|
||||||
if !ok {
|
if !ok && !updated {
|
||||||
if !updated {
|
|
||||||
zoneCache.update(nil, true)
|
zoneCache.update(nil, true)
|
||||||
zoneCache.RLock()
|
zoneCache.RLock()
|
||||||
name, ok = zoneCache.toName[index]
|
name, ok = zoneCache.toName[index]
|
||||||
zoneCache.RUnlock()
|
zoneCache.RUnlock()
|
||||||
}
|
}
|
||||||
}
|
if !ok { // last resort
|
||||||
if !ok {
|
|
||||||
name = uitoa(uint(index))
|
name = uitoa(uint(index))
|
||||||
}
|
}
|
||||||
return name
|
return name
|
||||||
@ -245,15 +243,13 @@ func (zc *ipv6ZoneCache) index(name string) int {
|
|||||||
zoneCache.RLock()
|
zoneCache.RLock()
|
||||||
index, ok := zoneCache.toIndex[name]
|
index, ok := zoneCache.toIndex[name]
|
||||||
zoneCache.RUnlock()
|
zoneCache.RUnlock()
|
||||||
if !ok {
|
if !ok && !updated {
|
||||||
if !updated {
|
|
||||||
zoneCache.update(nil, true)
|
zoneCache.update(nil, true)
|
||||||
zoneCache.RLock()
|
zoneCache.RLock()
|
||||||
index, ok = zoneCache.toIndex[name]
|
index, ok = zoneCache.toIndex[name]
|
||||||
zoneCache.RUnlock()
|
zoneCache.RUnlock()
|
||||||
}
|
}
|
||||||
}
|
if !ok { // last resort
|
||||||
if !ok {
|
|
||||||
index, _, _ = dtoi(name)
|
index, _, _ = dtoi(name)
|
||||||
}
|
}
|
||||||
return index
|
return index
|
||||||
|
Loading…
Reference in New Issue
Block a user