mirror of
https://github.com/hashicorp/terraform.git
synced 2026-05-28 04:03:27 -04:00
fix: pre allocate for composite literal
This commit is contained in:
parent
c0964438d6
commit
ef4798de8e
4 changed files with 5 additions and 5 deletions
|
|
@ -180,7 +180,7 @@ func (b *Backend) configure(ctx context.Context) error {
|
|||
if v, ok := data.GetOk("impersonate_service_account_delegates"); ok {
|
||||
d := v.([]interface{})
|
||||
if len(delegates) > 0 {
|
||||
delegates = make([]string, len(d))
|
||||
delegates = make([]string, 0, len(d))
|
||||
}
|
||||
for _, delegate := range d {
|
||||
delegates = append(delegates, delegate.(string))
|
||||
|
|
|
|||
|
|
@ -235,7 +235,7 @@ in order to capture the filesystem context the remote workspace expects:
|
|||
return nil, varDiags.Err()
|
||||
}
|
||||
|
||||
runVariables := make([]*tfe.RunVariable, len(variables))
|
||||
runVariables := make([]*tfe.RunVariable, 0, len(variables))
|
||||
for name, value := range variables {
|
||||
runVariables = append(runVariables, &tfe.RunVariable{
|
||||
Key: name,
|
||||
|
|
|
|||
|
|
@ -150,8 +150,8 @@ func (b *binary) Run(args ...string) (stdout, stderr string, err error) {
|
|||
// Path returns a file path within the temporary working directory by
|
||||
// appending the given arguments as path segments.
|
||||
func (b *binary) Path(parts ...string) string {
|
||||
args := make([]string, len(parts)+1)
|
||||
args[0] = b.workDir
|
||||
args := make([]string, 0, len(parts)+1)
|
||||
args = append(args, b.workDir)
|
||||
args = append(args, parts...)
|
||||
return filepath.Join(args...)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -259,7 +259,7 @@ func configschemaObjectToProto(b *configschema.Object) *proto.Schema_Object {
|
|||
nesting = proto.Schema_Object_INVALID
|
||||
}
|
||||
|
||||
attributes := make([]*proto.Schema_Attribute, len(b.Attributes))
|
||||
attributes := make([]*proto.Schema_Attribute, 0, len(b.Attributes))
|
||||
|
||||
for _, name := range sortedKeys(b.Attributes) {
|
||||
a := b.Attributes[name]
|
||||
|
|
|
|||
Loading…
Reference in a new issue