From db6b62ef76669b69c92f31cce98c98d7ef7ddb85 Mon Sep 17 00:00:00 2001 From: Valentin Kiselev Date: Mon, 2 Dec 2024 11:56:38 +0300 Subject: [PATCH] perf: allocate destCommands when we know the len of commands --- internal/config/load.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/config/load.go b/internal/config/load.go index 1196d216..585502c9 100644 --- a/internal/config/load.go +++ b/internal/config/load.go @@ -308,11 +308,11 @@ func addHook(name string, main, secondary *koanf.Koanf, c *Config) error { // Special merge func to support merging {cmd} templates options := koanf.WithMergeFunc(func(src, dest map[string]interface{}) error { - // perf: allocate with len of src commands here - destCommands := make(map[string]string) + var destCommands map[string]string switch commands := dest["commands"].(type) { case map[string]interface{}: + destCommands = make(map[string]string, len(commands)) for cmdName, command := range commands { switch cmd := command.(type) { case map[string]interface{}: