Browse Source

perf(route): preallocate parameters in route.Path

This function is called for every URL in templates, so reducing heap usage
is interesting.
jvoisin 3 weeks ago
parent
commit
9660e8a84d
1 changed files with 1 additions and 1 deletions
  1. 1 1
      internal/http/route/route.go

+ 1 - 1
internal/http/route/route.go

@@ -16,7 +16,7 @@ func Path(router *mux.Router, name string, args ...any) string {
 		panic("route not found: " + name)
 	}
 
-	var pairs []string
+	pairs := make([]string, 0, len(args))
 	for _, arg := range args {
 		switch param := arg.(type) {
 		case string: