optimization:Merge slices
This commit is contained in:
parent
383b0c176c
commit
9a97c348f0
|
@ -271,9 +271,7 @@ func (w *interpolationWalker) splitSlice() {
|
||||||
result = append(result, val.Value)
|
result = append(result, val.Value)
|
||||||
}
|
}
|
||||||
case []interface{}:
|
case []interface{}:
|
||||||
for _, element := range val {
|
result = append(result, val...)
|
||||||
result = append(result, element)
|
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
result = append(result, v)
|
result = append(result, v)
|
||||||
}
|
}
|
||||||
|
|
|
@ -144,12 +144,8 @@ func Merge(c1, c2 *Config) (*Config, error) {
|
||||||
// Explicit length check above because we want c.Locals to remain
|
// Explicit length check above because we want c.Locals to remain
|
||||||
// nil if the result would be empty.
|
// nil if the result would be empty.
|
||||||
c.Locals = make([]*Local, 0, len(c1.Locals)+len(c2.Locals))
|
c.Locals = make([]*Local, 0, len(c1.Locals)+len(c2.Locals))
|
||||||
for _, v := range c1.Locals {
|
c.Locals = append(c.Locals, c1.Locals...)
|
||||||
c.Locals = append(c.Locals, v)
|
c.Locals = append(c.Locals, c2.Locals...)
|
||||||
}
|
|
||||||
for _, v := range c2.Locals {
|
|
||||||
c.Locals = append(c.Locals, v)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return c, nil
|
return c, nil
|
||||||
|
|
|
@ -42,9 +42,9 @@ func (r *ResourceAddress) Copy() *ResourceAddress {
|
||||||
Type: r.Type,
|
Type: r.Type,
|
||||||
Mode: r.Mode,
|
Mode: r.Mode,
|
||||||
}
|
}
|
||||||
for _, p := range r.Path {
|
|
||||||
n.Path = append(n.Path, p)
|
n.Path = append(n.Path, r.Path...)
|
||||||
}
|
|
||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue