From 46f2b8be7b66aada47660feb94c9834d579a5272 Mon Sep 17 00:00:00 2001 From: box4wangjing Date: Tue, 12 May 2026 04:38:51 +0900 Subject: [PATCH] refactor: replace Split in loops with more efficient SplitSeq (#2969) * refactor: replace Split in loops with more efficient SplitSeq Signed-off-by: box4wangjing * refactor: replace Split in loops with more efficient SplitSeq Signed-off-by: box4wangjing --------- Signed-off-by: box4wangjing --- middleware/extractor.go | 4 ++-- router_test.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/middleware/extractor.go b/middleware/extractor.go index abb60318..f800a49e 100644 --- a/middleware/extractor.go +++ b/middleware/extractor.go @@ -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) diff --git a/router_test.go b/router_test.go index 7bddb4a1..69b8d4a6 100644 --- a/router_test.go +++ b/router_test.go @@ -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) }