Performance: add preallocation for some slice/map (#57860)

This change preallocates slices and maps where the size of the data is known before the object is created.

Co-authored-by: Joe Blubaugh <joe.blubaugh@grafana.com>
This commit is contained in:
Denis Limarev
2022-11-22 18:24:36 +06:00
committed by GitHub
parent 460be70261
commit 4d8287b319
8 changed files with 15 additions and 13 deletions

View File

@ -87,7 +87,7 @@ func (i *Initializer) awsEnvVars() []string {
type pluginSettings map[string]string
func (ps pluginSettings) asEnvVar(prefix string, hostEnv []string) []string {
var env []string
env := make([]string, 0, len(ps))
for k, v := range ps {
key := fmt.Sprintf("%s_%s", prefix, strings.ToUpper(k))
if value := os.Getenv(key); value != "" {