Преглед изворни кода

all: prefer strings.LastIndexByte over strings.LastIndex

strings.LastIndexByte was introduced in go1.5 and it can be used
effectively wherever the second argument to strings.LastIndex is
exactly one byte long.

This avoids generating unnecessary string symbols and saves
a few calls to strings.LastIndex.

Change-Id: I7b5679d616197b055cffe6882a8675d24a98b574
Reviewed-on: https://go-review.googlesource.com/66372
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
tls13
Marvin Stenger пре 7 година
committed by Ian Lance Taylor
родитељ
комит
d547ccf7ac
2 измењених фајлова са 2 додато и 2 уклоњено
  1. +1
    -1
      handshake_client.go
  2. +1
    -1
      tls.go

+ 1
- 1
handshake_client.go Прегледај датотеку

@@ -848,7 +848,7 @@ func hostnameInSNI(name string) string {
if len(host) > 0 && host[0] == '[' && host[len(host)-1] == ']' {
host = host[1 : len(host)-1]
}
if i := strings.LastIndex(host, "%"); i > 0 {
if i := strings.LastIndexByte(host, '%'); i > 0 {
host = host[:i]
}
if net.ParseIP(host) != nil {


+ 1
- 1
tls.go Прегледај датотеку

@@ -122,7 +122,7 @@ func DialWithDialer(dialer *net.Dialer, network, addr string, config *Config) (*
return nil, err
}

colonPos := strings.LastIndex(addr, ":")
colonPos := strings.LastIndexByte(addr, ':')
if colonPos == -1 {
colonPos = len(addr)
}


Loading…
Откажи
Сачувај