From 404c8a896896943715f8fb3906a8d054fae17d3e Mon Sep 17 00:00:00 2001 From: tyltr Date: Mon, 29 Aug 2022 13:51:37 +0800 Subject: [PATCH] Chore (#1365) * chore-1 * chore2 --- bytesconv.go | 4 +--- peripconn.go | 4 +++- uri.go | 12 +++--------- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/bytesconv.go b/bytesconv.go index a12bb95..4759aa6 100644 --- a/bytesconv.go +++ b/bytesconv.go @@ -252,9 +252,7 @@ var ( ) func readHexInt(r *bufio.Reader) (int, error) { - n := 0 - i := 0 - var k int + var k, i, n int for { c, err := r.ReadByte() if err != nil { diff --git a/peripconn.go b/peripconn.go index afd2a92..c2d1827 100644 --- a/peripconn.go +++ b/peripconn.go @@ -48,8 +48,10 @@ type perIPConn struct { func acquirePerIPConn(conn net.Conn, ip uint32, counter *perIPConnCounter) *perIPConn { v := counter.pool.Get() if v == nil { - v = &perIPConn{ + return &perIPConn{ perIPConnCounter: counter, + Conn: conn, + ip: ip, } } c := v.(*perIPConn) diff --git a/uri.go b/uri.go index f894b1b..ab4cc65 100644 --- a/uri.go +++ b/uri.go @@ -538,15 +538,9 @@ func shouldEscape(c byte, mode encoding) bool { } func ishex(c byte) bool { - switch { - case '0' <= c && c <= '9': - return true - case 'a' <= c && c <= 'f': - return true - case 'A' <= c && c <= 'F': - return true - } - return false + return ('0' <= c && c <= '9') || + ('a' <= c && c <= 'f') || + ('A' <= c && c <= 'F') } func unhex(c byte) byte {