aboutsummaryrefslogtreecommitdiff
path: root/src/net/interface.go
diff options
context:
space:
mode:
authorMikio Hara <mikioh.public.networking@gmail.com>2018-11-08 09:48:55 +0900
committerMikio Hara <mikioh.public.networking@gmail.com>2018-11-08 08:19:48 +0000
commit7da1f7addf54e55c7b40c1a7bffe5a64989154d8 (patch)
tree856082a9c7261ec37dfded02428e5983d50928cf /src/net/interface.go
parent05a85f493c046967bd6d94392ff6f5fda1a8703e (diff)
downloadgo-7da1f7addf54e55c7b40c1a7bffe5a64989154d8.tar.xz
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>
Diffstat (limited to 'src/net/interface.go')
-rw-r--r--src/net/interface.go28
1 files changed, 12 insertions, 16 deletions
diff --git a/src/net/interface.go b/src/net/interface.go
index 46b0400f2f..f68df98aa2 100644
--- a/src/net/interface.go
+++ b/src/net/interface.go
@@ -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
@@ -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