Skip to content
Myr

perf(all): use strings.Cut to replace strings.SplitN (#4239)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Name · committed by GitHub · parent 2e2bd1f · Browse files · 2 files+5 added−5 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Trailers

  • Co-authored-by: 1911860538 <alxps1911@gmail.com>

Diff stats

2 files+5 added−5 removed

  • other:+5 added−5 removed

2 files+5 added−5 removed

modified:recovery.go+3 added-3 removed
72 unmodified lines
73 stack := stack(3)74 httpRequest, _ := httputil.DumpRequest(c.Request, false)75 headers := strings.Split(string(httpRequest), "\r\n")76 for idx, header := range headers {77 current := strings.Split(header, ":")78 if current[0] == "Authorization" {79 headers[idx] = current[0] + ": *"77 key, _, _ := strings.Cut(header, ":")78 if key == "Authorization" {79 headers[idx] = key + ": *"80 }81 }82 headersToStr := strings.Join(headers, "\r\n")83 if brokenPipe {
91 unmodified lines
modified:tree.go+2 added-2 removed
232 unmodified lines
233234 // Wildcard conflict235 pathSeg := path236 if n.nType != catchAll {237 pathSeg = strings.SplitN(pathSeg, "/", 2)[0]237 pathSeg, _, _ = strings.Cut(pathSeg, "/")238 }239 prefix := fullPath[:strings.Index(fullPath, pathSeg)] + n.path240 panic("'" + pathSeg +241 "' in new path '" + fullPath +
115 unmodified lines
357358 if len(n.path) > 0 && n.path[len(n.path)-1] == '/' {359 pathSeg := ""360 if len(n.children) != 0 {361 pathSeg = strings.SplitN(n.children[0].path, "/", 2)[0]361 pathSeg, _, _ = strings.Cut(n.children[0].path, "/")362 }363 panic("catch-all wildcard '" + path +364 "' in new path '" + fullPath +365 "' conflicts with existing path segment '" + pathSeg +
535 unmodified lines