Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix slice init length #8091

Merged
merged 1 commit into from
Oct 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion grove/remap/remap.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ func (r literalPrefixRemapper) Remap(s string) (remapdata.RemapRule, bool) {
}

func (r literalPrefixRemapper) Rules() []remapdata.RemapRule {
rules := make([]remapdata.RemapRule, len(r.remap))
rules := make([]remapdata.RemapRule, 0, len(r.remap))
for _, rule := range r.remap {
rules = append(rules, rule)
}
Expand Down
2 changes: 1 addition & 1 deletion grove/stat/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ func (s statsRemaps) Stats(rule string) (StatsRemap, bool) {
}

func (s statsRemaps) Rules() []string {
rules := make([]string, len(s))
rules := make([]string, 0, len(s))
for rule := range s {
rules = append(rules, rule)
}
Expand Down
2 changes: 1 addition & 1 deletion traffic_ops/traffic_ops_golang/monitoring/monitoring.go
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ func getProfiles(tx *sql.Tx, caches []Cache, routers []Router) ([]Profile, error
}
}

profilesArr := make([]Profile, len([]Profile{}))
profilesArr := make([]Profile, 0, len([]Profile{}))
for _, profile := range profiles {
profilesArr = append(profilesArr, profile)
}
Expand Down
4 changes: 2 additions & 2 deletions traffic_ops/traffic_ops_golang/topology/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func checkForSelfParents(nodes []tc.TopologyNode, index int) error {
func checkForEdgeParents(topology tc.TopologyV5, cacheGroups []tc.CacheGroupNullable, nodeIndex int) (tc.Alerts, error) {
var alerts tc.Alerts
node := topology.Nodes[nodeIndex]
errs := make([]error, len(node.Parents))
errs := make([]error, 0, len(node.Parents))
for parentIndex, parentCacheGroupIndex := range node.Parents {
if parentCacheGroupIndex < 0 || parentCacheGroupIndex >= len(topology.Nodes) {
errs = append(errs, fmt.Errorf("parent %d of cachegroup %s refers to a cachegroup at index %d, but no such cachegroup exists", parentIndex, node.Cachegroup, parentCacheGroupIndex))
Expand Down Expand Up @@ -99,7 +99,7 @@ func checkForEdgeParents(topology tc.TopologyV5, cacheGroups []tc.CacheGroupNull
// an edge parents an edge, and returns an error if an edge parents a non-edge cachegroup.
func (topology *TOTopology) checkForEdgeParents(cacheGroups []tc.CacheGroupNullable, nodeIndex int) error {
node := topology.Nodes[nodeIndex]
errs := make([]error, len(node.Parents))
errs := make([]error, 0, len(node.Parents))
for parentIndex, parentCacheGroupIndex := range node.Parents {
if parentCacheGroupIndex < 0 || parentCacheGroupIndex >= len(topology.Nodes) {
errs = append(errs, fmt.Errorf("parent %d of cachegroup %s refers to a cachegroup at index %d, but no such cachegroup exists", parentIndex, node.Cachegroup, parentCacheGroupIndex))
Expand Down
Loading