Skip to content

Commit

Permalink
Merge pull request #32261 from sivchari/fix-prealloc
Browse files Browse the repository at this point in the history
fix: pre allocate for composite literal
  • Loading branch information
jbardin committed Nov 22, 2022
2 parents e6653f9 + ef4798d commit 79175b2
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion internal/backend/remote-state/gcs/backend.go
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion internal/cloud/backend_plan.go
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions internal/e2e/e2e.go
Expand Up @@ -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...)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/plugin6/convert/schema.go
Expand Up @@ -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]
Expand Down

0 comments on commit 79175b2

Please sign in to comment.