]> Cypherpunks repositories - gostls13.git/commitdiff
net: simplify nested if-blocks
authorMikio Hara <mikioh.public.networking@gmail.com>
Thu, 8 Nov 2018 00:48:55 +0000 (09:48 +0900)
committerMikio Hara <mikioh.public.networking@gmail.com>
Thu, 8 Nov 2018 08:19:48 +0000 (08:19 +0000)
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>
src/net/interface.go

index 46b0400f2f5ecadf50d7979705c408120b86cd08..f68df98aa27669d0bcbd7d6babc002434b751632 100644 (file)
@@ -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