[#493] ir: Use pre-allocation in initHTTPServers function
Number of servers to be created is known in advance. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
c340d77b74
commit
ece6618560
1 changed files with 6 additions and 4 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue