From e851ac5d262c3c35e4d969f4ab64828ba811154f Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 18 Jun 2013 09:30:23 -0700 Subject: [PATCH] packer: Avoid an extra allocation by using clever addressing --- packer/template.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/packer/template.go b/packer/template.go index c08ab0cde..bdb8185c0 100644 --- a/packer/template.go +++ b/packer/template.go @@ -126,8 +126,8 @@ func ParseTemplate(data []byte) (t *Template, err error) { t.PostProcessors[i] = make([]rawPostProcessorConfig, len(rawPP)) configs := t.PostProcessors[i] for j, pp := range rawPP { - var config rawPostProcessorConfig - if err := mapstructure.Decode(pp, &config); err != nil { + config := &configs[j] + if err := mapstructure.Decode(pp, config); err != nil { if merr, ok := err.(*mapstructure.Error); ok { for _, err := range merr.Errors { errors = append(errors, fmt.Errorf("Post-processor #%d.%d: %s", i+1, j+1, err)) @@ -145,8 +145,6 @@ func ParseTemplate(data []byte) (t *Template, err error) { } config.rawConfig = pp - - configs[j] = config } }