Skip to content

Commit

Permalink
perf: allocate destCommands when we know the len of commands
Browse files Browse the repository at this point in the history
  • Loading branch information
mrexox committed Dec 2, 2024
1 parent 1ad2903 commit db6b62e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions internal/config/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}:
Expand Down

0 comments on commit db6b62e

Please sign in to comment.