preallocated slices (#917)

This commit is contained in:
Till Knuesting
2019-11-05 17:43:12 +00:00
committed by Asim Aslam
parent 4a694c9d02
commit f67c5e779f
10 changed files with 10 additions and 10 deletions

View File

@@ -101,7 +101,7 @@ func (r *routerSelector) getRoutes(service string) ([]router.Route, error) {
return nil, selector.ErrNoneAvailable
}
var routes []router.Route
routes := make([]router.Route, 0, len(pbRoutes.Routes))
// convert from pb to []*router.Route
for _, r := range pbRoutes.Routes {

View File

@@ -14,7 +14,7 @@ func init() {
// Random is a random strategy algorithm for node selection
func Random(services []*registry.Service) Next {
var nodes []*registry.Node
nodes := make([]*registry.Node, 0, len(services))
for _, service := range services {
nodes = append(nodes, service.Nodes...)