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:
@@ -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
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user