net/netip: use built-in clear to simplify code

This commit is contained in:
apocelipes 2024-03-14 19:23:10 +09:00
parent f1d60500bc
commit a7194571e1

View 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"}