]> Cypherpunks repositories - gostls13.git/commitdiff
net/netip: use built-in clear to simplify code
authorapocelipes <seve3r@outlook.com>
Thu, 14 Mar 2024 10:41:08 +0000 (10:41 +0000)
committerGopher Robot <gobot@golang.org>
Thu, 14 Mar 2024 20:28:37 +0000 (20:28 +0000)
Change-Id: Ic7b390935df107c5b7f53f9347a52031eac8a897
GitHub-Last-Rev: a7194571e1c2f90537f1caa8a3b5bcd60cea60be
GitHub-Pull-Request: golang/go#66310
Reviewed-on: https://go-review.googlesource.com/c/go/+/571635
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: qiulaidongfeng <2645477756@qq.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
src/net/netip/netip.go

index d709c56dfa8b479cd07ff00dc7da6218c3c22bb6..b613a5c82f6b90e641054f49e10ccd1f6b677676 100644 (file)
@@ -335,9 +335,7 @@ func parseIPv6(in string) (Addr, error) {
                for j := i - 1; j >= ellipsis; j-- {
                        ip[j+n] = ip[j]
                }
-               for j := ellipsis + n - 1; j >= ellipsis; j-- {
-                       ip[j] = 0
-               }
+               clear(ip[ellipsis : ellipsis+n])
        } else if ellipsis >= 0 {
                // Ellipsis must represent at least one 0 group.
                return Addr{}, parseAddrError{in: in, msg: "the :: must expand to at least one field of zeros"}