[#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 {
|
func initHTTPServers(cfg *viper.Viper) []*httputil.Server {
|
||||||
var httpServers []*httputil.Server
|
items := []struct {
|
||||||
|
|
||||||
for _, item := range []struct {
|
|
||||||
cfgPrefix string
|
cfgPrefix string
|
||||||
handler func() http.Handler
|
handler func() http.Handler
|
||||||
}{
|
}{
|
||||||
{"profiler", httputil.Handler},
|
{"profiler", httputil.Handler},
|
||||||
{"metrics", promhttp.Handler},
|
{"metrics", promhttp.Handler},
|
||||||
} {
|
}
|
||||||
|
|
||||||
|
httpServers := make([]*httputil.Server, 0, len(items))
|
||||||
|
|
||||||
|
for _, item := range items {
|
||||||
addr := cfg.GetString(item.cfgPrefix + ".address")
|
addr := cfg.GetString(item.cfgPrefix + ".address")
|
||||||
if addr == "" {
|
if addr == "" {
|
||||||
continue
|
continue
|
||||||
|
|
Loading…
Reference in a new issue