From ece6618560b00e4ea16fd045fd385eb7c6644515 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Wed, 12 May 2021 10:37:58 +0300 Subject: [PATCH] [#493] ir: Use pre-allocation in initHTTPServers function Number of servers to be created is known in advance. Signed-off-by: Leonard Lyubich --- cmd/neofs-ir/main.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cmd/neofs-ir/main.go b/cmd/neofs-ir/main.go index c1a262fd..610f1124 100644 --- a/cmd/neofs-ir/main.go +++ b/cmd/neofs-ir/main.go @@ -130,15 +130,17 @@ func parsePublicKeysFromString(argument string) (keys.PublicKeys, error) { } func initHTTPServers(cfg *viper.Viper) []*httputil.Server { - var httpServers []*httputil.Server - - for _, item := range []struct { + items := []struct { cfgPrefix string handler func() http.Handler }{ {"profiler", httputil.Handler}, {"metrics", promhttp.Handler}, - } { + } + + httpServers := make([]*httputil.Server, 0, len(items)) + + for _, item := range items { addr := cfg.GetString(item.cfgPrefix + ".address") if addr == "" { continue