mirror of
https://github.com/opentofu/opentofu.git
synced 2025-01-15 19:22:46 -06:00
Merge pull request #32261 from sivchari/fix-prealloc
fix: pre allocate for composite literal
This commit is contained in:
commit
79175b29f3
@ -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 New Issue
Block a user