Skip to content

Commit

Permalink
fix: fix slice init length (GoogleCloudPlatform#11919)
Browse files Browse the repository at this point in the history
  • Loading branch information
cuishuang authored and BBBmau committed Nov 5, 2024
1 parent 5835fa7 commit 5c20337
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions mmv1/templates/terraform/unordered_list_customize_diff.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ if oldCount.(int) < newCount.(int) {
if count < 1 {
return nil
}
old := make([]interface{}, count)
new := make([]interface{}, count)
old := make([]interface{}, 0, count)
new := make([]interface{}, 0, count)
for i := 0; i < count; i++ {
o, n := diff.GetChange(fmt.Sprintf("<%= prop.name.underscore -%>.%d", i))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ if oldCount.(int) < newCount.(int) {
if count < 1 {
return nil
}
old := make([]interface{}, count)
new := make([]interface{}, count)
old := make([]interface{}, 0, count)
new := make([]interface{}, 0, count)
for i := 0; i < count; i++ {
o, n := diff.GetChange(fmt.Sprintf("{{ underscore $.Name }}.%d", i))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func BetaMetadataUpdate(oldMDMap map[string]interface{}, newMDMap map[string]int
}

func expandComputeMetadata(m map[string]interface{}) []*compute.MetadataItems {
metadata := make([]*compute.MetadataItems, len(m))
metadata := make([]*compute.MetadataItems, 0, len(m))
var keys []string
for key := range m {
keys = append(keys, key)
Expand Down
4 changes: 2 additions & 2 deletions tpgtools/ignored_handwritten/common_custom_diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ func resourceComputeSubnetworkSecondaryIpRangeSetStyleDiff(diff *schema.Resource
if count < 1 {
return nil
}
old := make([]interface{}, count)
new := make([]interface{}, count)
old := make([]interface{}, 0, count)
new := make([]interface{}, 0, count)
for i := 0; i < count; i++ {
o, n := diff.GetChange(fmt.Sprintf("secondary_ip_range.%d", i))

Expand Down

0 comments on commit 5c20337

Please sign in to comment.