refactor: replace Split in loops with more efficient SplitSeq (#6187)
Signed-off-by: questfever <questfever@outlook.com>
This commit is contained in:
parent
14d757ce1f
commit
011a0e8360
4 changed files with 4 additions and 4 deletions
|
|
@ -206,7 +206,7 @@ func parseFullyQualifiedEmoji(data []byte) ([]string, int) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
var sequence strings.Builder
|
var sequence strings.Builder
|
||||||
for _, field := range strings.Fields(fields[0]) {
|
for field := range strings.FieldsSeq(fields[0]) {
|
||||||
sequence.WriteRune(parseCodePoint(field))
|
sequence.WriteRune(parseCodePoint(field))
|
||||||
}
|
}
|
||||||
emoji := sequence.String()
|
emoji := sequence.String()
|
||||||
|
|
|
||||||
|
|
@ -219,7 +219,7 @@ func testCookieExpiry() time.Time {
|
||||||
}
|
}
|
||||||
|
|
||||||
func containsCookieAttribute(cookie, attr string) bool {
|
func containsCookieAttribute(cookie, attr string) bool {
|
||||||
for _, part := range strings.Split(cookie, ";") {
|
for part := range strings.SplitSeq(cookie, ";") {
|
||||||
if strings.EqualFold(strings.TrimSpace(part), attr) {
|
if strings.EqualFold(strings.TrimSpace(part), attr) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -198,7 +198,7 @@ func isSecureRequest(ctx context.Context) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, value := range md.Get("x-forwarded-proto") {
|
for _, value := range md.Get("x-forwarded-proto") {
|
||||||
for _, proto := range strings.Split(value, ",") {
|
for proto := range strings.SplitSeq(value, ",") {
|
||||||
if strings.EqualFold(strings.TrimSpace(proto), "https") {
|
if strings.EqualFold(strings.TrimSpace(proto), "https") {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -306,7 +306,7 @@ func synthesizeGatewayVariable(segment string) []string {
|
||||||
}
|
}
|
||||||
|
|
||||||
var built []string
|
var built []string
|
||||||
for _, part := range strings.Split(subtemplate, "/") {
|
for part := range strings.SplitSeq(subtemplate, "/") {
|
||||||
switch part {
|
switch part {
|
||||||
case "*":
|
case "*":
|
||||||
built = append(built, "one")
|
built = append(built, "one")
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue