]> Cypherpunks repositories - gostls13.git/commitdiff
net: clean up redundant if branch in dial
authorShang Ding <sding3@ncsu.edu>
Thu, 24 Feb 2022 01:35:21 +0000 (19:35 -0600)
committerTobias Klauser <tobias.klauser@gmail.com>
Thu, 31 Mar 2022 06:40:26 +0000 (06:40 +0000)
Dialer.DialContext no longer performs a redundant check on the length
of the fallback slice, because dialParallel already handles the
situation where the fallback slice is empty or nil.

Change-Id: Ibb16f4813fc55dec2939c54c10e665ff35bfe163
Reviewed-on: https://go-review.googlesource.com/c/go/+/387795
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
src/net/dial.go

index 486ced0f2a99c2775ceeca78c648ab7678e7d680..9159e6b38447f7e3844ec63959b59d2e1b386299 100644 (file)
@@ -421,12 +421,7 @@ func (d *Dialer) DialContext(ctx context.Context, network, address string) (Conn
                primaries = addrs
        }
 
-       var c Conn
-       if len(fallbacks) > 0 {
-               c, err = sd.dialParallel(ctx, primaries, fallbacks)
-       } else {
-               c, err = sd.dialSerial(ctx, primaries)
-       }
+       c, err := sd.dialParallel(ctx, primaries, fallbacks)
        if err != nil {
                return nil, err
        }