Commit e851ac5d authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

packer: Avoid an extra allocation by using clever addressing

parent 7a07802e
...@@ -126,8 +126,8 @@ func ParseTemplate(data []byte) (t *Template, err error) { ...@@ -126,8 +126,8 @@ func ParseTemplate(data []byte) (t *Template, err error) {
t.PostProcessors[i] = make([]rawPostProcessorConfig, len(rawPP)) t.PostProcessors[i] = make([]rawPostProcessorConfig, len(rawPP))
configs := t.PostProcessors[i] configs := t.PostProcessors[i]
for j, pp := range rawPP { for j, pp := range rawPP {
var config rawPostProcessorConfig config := &configs[j]
if err := mapstructure.Decode(pp, &config); err != nil { if err := mapstructure.Decode(pp, config); err != nil {
if merr, ok := err.(*mapstructure.Error); ok { if merr, ok := err.(*mapstructure.Error); ok {
for _, err := range merr.Errors { for _, err := range merr.Errors {
errors = append(errors, fmt.Errorf("Post-processor #%d.%d: %s", i+1, j+1, err)) 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) { ...@@ -145,8 +145,6 @@ func ParseTemplate(data []byte) (t *Template, err error) {
} }
config.rawConfig = pp config.rawConfig = pp
configs[j] = config
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment