1
0
mirror of https://github.com/labstack/echo.git synced 2026-05-16 09:48:24 +02:00

refactor: replace Split in loops with more efficient SplitSeq (#2969)

* refactor: replace Split in loops with more efficient SplitSeq

Signed-off-by: box4wangjing <box4wangjing@outlook.com>

* refactor: replace Split in loops with more efficient SplitSeq

Signed-off-by: box4wangjing <box4wangjing@outlook.com>

---------

Signed-off-by: box4wangjing <box4wangjing@outlook.com>
This commit is contained in:
box4wangjing
2026-05-12 04:38:51 +09:00
committed by GitHub
parent 7d1fed0542
commit 46f2b8be7b
2 changed files with 4 additions and 4 deletions
+2 -2
View File
@@ -85,9 +85,9 @@ func createExtractors(lookups string, limit uint) ([]ValuesExtractor, error) {
limit = extractorLimit
}
sources := strings.Split(lookups, ",")
sources := strings.SplitSeq(lookups, ",")
var extractors = make([]ValuesExtractor, 0)
for _, source := range sources {
for source := range sources {
parts := strings.Split(source, ":")
if len(parts) < 2 {
return nil, fmt.Errorf("extractor source for lookup could not be split into needed parts: %v", source)
+2 -2
View File
@@ -2235,8 +2235,8 @@ func testRouterAPI(t *testing.T, api []testRoute) {
c.SetRequest(httptest.NewRequest(route.Method, route.Path, nil))
e.router.Route(c)
tokens := strings.Split(route.Path[1:], "/")
for _, token := range tokens {
tokens := strings.SplitSeq(route.Path[1:], "/")
for token := range tokens {
if token[0] == ':' {
assert.Equal(t, c.pathValues.GetOr(token[1:], "---none---"), token)
}