From 6758dd8987217b00c81939a56124df5fae8d9851 Mon Sep 17 00:00:00 2001 From: Ajat Prabha Date: Fri, 9 Feb 2024 12:17:39 +0530 Subject: [PATCH] refactor: remove unnecessary allocation (#34) --- xload/providers/viper/options.go | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/xload/providers/viper/options.go b/xload/providers/viper/options.go index 1fa5cc9..a5505a5 100644 --- a/xload/providers/viper/options.go +++ b/xload/providers/viper/options.go @@ -82,16 +82,8 @@ func def() *options { ext: "yaml", paths: []string{"./", "../"}, }, - autoEnv: true, - mapValues: func(in map[string]any) map[string]string { - out := make(map[string]string) - - for key, value := range xload.FlattenMap(in, "_") { - out[key] = value - } - - return out - }, + autoEnv: true, + mapValues: func(in map[string]any) map[string]string { return xload.FlattenMap(in, "_") }, transform: func(_ *viper.Viper, next xload.Loader) xload.Loader { return xload.LoaderFunc(func(ctx context.Context, key string) (string, error) { return next.Load(ctx, strings.ToLower(key))