optimization:Merge slices

This commit is contained in:
Wang Guoliang 2017-09-13 21:04:55 +08:00
parent 383b0c176c
commit 9a97c348f0
No known key found for this signature in database
GPG Key ID: 55EC13D4306ABFE4
3 changed files with 6 additions and 12 deletions

View File

@ -271,9 +271,7 @@ func (w *interpolationWalker) splitSlice() {
result = append(result, val.Value)
}
case []interface{}:
for _, element := range val {
result = append(result, element)
}
result = append(result, val...)
default:
result = append(result, v)
}

View File

@ -144,12 +144,8 @@ func Merge(c1, c2 *Config) (*Config, error) {
// Explicit length check above because we want c.Locals to remain
// nil if the result would be empty.
c.Locals = make([]*Local, 0, len(c1.Locals)+len(c2.Locals))
for _, v := range c1.Locals {
c.Locals = append(c.Locals, v)
}
for _, v := range c2.Locals {
c.Locals = append(c.Locals, v)
}
c.Locals = append(c.Locals, c1.Locals...)
c.Locals = append(c.Locals, c2.Locals...)
}
return c, nil

View File

@ -42,9 +42,9 @@ func (r *ResourceAddress) Copy() *ResourceAddress {
Type: r.Type,
Mode: r.Mode,
}
for _, p := range r.Path {
n.Path = append(n.Path, p)
}
n.Path = append(n.Path, r.Path...)
return n
}