From 199e1e2168c11e0be10d3f4c0e687ed50998e2e3 Mon Sep 17 00:00:00 2001 From: yzy613 Date: Mon, 6 Nov 2023 10:15:24 +0800 Subject: [PATCH] perf: ExpandIPv6Zero --- go.mod | 4 ++-- go.sum | 8 ++++---- internal/common/common.go | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/go.mod b/go.mod index 98fcffa..a6fd2ad 100644 --- a/go.mod +++ b/go.mod @@ -3,9 +3,9 @@ module ddns-watchdog go 1.21 require ( - github.com/aliyun/alibaba-cloud-sdk-go v1.62.587 + github.com/aliyun/alibaba-cloud-sdk-go v1.62.600 github.com/bitly/go-simplejson v0.5.1 - github.com/huaweicloud/huaweicloud-sdk-go-v3 v0.1.62 + github.com/huaweicloud/huaweicloud-sdk-go-v3 v0.1.64 github.com/spf13/pflag v1.0.5 ) diff --git a/go.sum b/go.sum index d9f5937..194212b 100644 --- a/go.sum +++ b/go.sum @@ -4,8 +4,8 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03 github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/HdrHistogram/hdrhistogram-go v1.1.2/go.mod h1:yDgFjdqOqDEKOvasDdhWNXYg9BVp4O+o5f6V/ehm6Oo= github.com/ajstarks/svgo v0.0.0-20180226025133-644b8db467af/go.mod h1:K08gAheRH3/J6wwsYMMT4xOr94bZjxIelGM0+d/wbFw= -github.com/aliyun/alibaba-cloud-sdk-go v1.62.587 h1:R7QQjLc0y4eI2fqHrW2bsjhYzAQqpI1yxi11gZiETYU= -github.com/aliyun/alibaba-cloud-sdk-go v1.62.587/go.mod h1:CJJYa1ZMxjlN/NbXEwmejEnBkhi0DV+Yb3B2lxf+74o= +github.com/aliyun/alibaba-cloud-sdk-go v1.62.600 h1:MFkvRajk5tsEPTkNyEVhMmYGOGOhiApTAcFkEIRf37w= +github.com/aliyun/alibaba-cloud-sdk-go v1.62.600/go.mod h1:CJJYa1ZMxjlN/NbXEwmejEnBkhi0DV+Yb3B2lxf+74o= github.com/bitly/go-simplejson v0.5.1 h1:xgwPbetQScXt1gh9BmoJ6j9JMr3TElvuIyjR8pgdoow= github.com/bitly/go-simplejson v0.5.1/go.mod h1:YOPVLzCfwK14b4Sff3oP1AmGhI9T9Vsg84etUnlyp+Q= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= @@ -42,8 +42,8 @@ github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.4 h1:L8R9j+yAqZuZjsqh/z+F1NCffTKKLShY6zXTItVIZ8M= github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/huaweicloud/huaweicloud-sdk-go-v3 v0.1.62 h1:KIdJHehTBMAe9rWllPWZsQ4ERMP89zVcu2JyNwHgrEI= -github.com/huaweicloud/huaweicloud-sdk-go-v3 v0.1.62/go.mod h1:AZT3IyeViMA1qIoo6lM2eDobcTXORpqIQzSqdodah7E= +github.com/huaweicloud/huaweicloud-sdk-go-v3 v0.1.64 h1:ESkUy969zejtfYMWUj5exYKM/bqYbQZZNhcO2WBBTKA= +github.com/huaweicloud/huaweicloud-sdk-go-v3 v0.1.64/go.mod h1:AZT3IyeViMA1qIoo6lM2eDobcTXORpqIQzSqdodah7E= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= diff --git a/internal/common/common.go b/internal/common/common.go index d2f9610..972dcc1 100644 --- a/internal/common/common.go +++ b/internal/common/common.go @@ -142,12 +142,12 @@ func ExpandIPv6Zero(ip string) string { b := make([]byte, 0, maxLen) const hexDigit = "0123456789abcdef" - appendHex := func(dst []byte, i uint) []byte { + appendHex := func(dst []byte, i uint16) []byte { if i == 0 { return append(dst, '0') } - for j := 7; j >= 0; j-- { - v := i >> uint(j*4) + for j := 3; j >= 0; j-- { + v := i >> (j * 4) if v > 0 { dst = append(dst, hexDigit[v&0xf]) } @@ -159,7 +159,7 @@ func ExpandIPv6Zero(ip string) string { if i > 0 { b = append(b, ':') } - b = appendHex(b, (uint(p[i])<<8)|uint(p[i+1])) + b = appendHex(b, (uint16(p[i])<<8)|uint16(p[i+1])) } return string(b) }