Skip to content

Commit

Permalink
net: simplify nested if-blocks
Browse files Browse the repository at this point in the history
Change-Id: I32e1829c955a48d8c4566430c13679e237bb0611
Reviewed-on: https://go-review.googlesource.com/c/148337
Run-TryBot: Mikio Hara <[email protected]>
TryBot-Result: Gobot Gobot <[email protected]>
Reviewed-by: Ian Lance Taylor <[email protected]>
  • Loading branch information
mikioh committed Nov 8, 2018
1 parent 05a85f4 commit 7da1f7a
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions src/net/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,15 +223,13 @@ func (zc *ipv6ZoneCache) name(index int) string {
zoneCache.RLock()
name, ok := zoneCache.toName[index]
zoneCache.RUnlock()
if !ok {
if !updated {
zoneCache.update(nil, true)
zoneCache.RLock()
name, ok = zoneCache.toName[index]
zoneCache.RUnlock()
}
if !ok && !updated {
zoneCache.update(nil, true)
zoneCache.RLock()
name, ok = zoneCache.toName[index]
zoneCache.RUnlock()
}
if !ok {
if !ok { // last resort
name = uitoa(uint(index))
}
return name
Expand All @@ -245,15 +243,13 @@ func (zc *ipv6ZoneCache) index(name string) int {
zoneCache.RLock()
index, ok := zoneCache.toIndex[name]
zoneCache.RUnlock()
if !ok {
if !updated {
zoneCache.update(nil, true)
zoneCache.RLock()
index, ok = zoneCache.toIndex[name]
zoneCache.RUnlock()
}
if !ok && !updated {
zoneCache.update(nil, true)
zoneCache.RLock()
index, ok = zoneCache.toIndex[name]
zoneCache.RUnlock()
}
if !ok {
if !ok { // last resort
index, _, _ = dtoi(name)
}
return index
Expand Down

0 comments on commit 7da1f7a

Please sign in to comment.