From: apocelipes Date: Thu, 14 Mar 2024 10:41:08 +0000 (+0000) Subject: net/netip: use built-in clear to simplify code X-Git-Tag: go1.23rc1~884 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=1d96895ccbea79daa9d6538bf9da6a4dd197336b;p=gostls13.git net/netip: use built-in clear to simplify code 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 Reviewed-by: qiulaidongfeng <2645477756@qq.com> Auto-Submit: Ian Lance Taylor Reviewed-by: Cherry Mui Reviewed-by: Ian Lance Taylor --- diff --git a/src/net/netip/netip.go b/src/net/netip/netip.go index d709c56dfa..b613a5c82f 100644 --- a/src/net/netip/netip.go +++ b/src/net/netip/netip.go @@ -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"}