-
Notifications
You must be signed in to change notification settings - Fork 474
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
*: Enable the prealloc linter #10762
base: main
Are you sure you want to change the base?
*: Enable the prealloc linter #10762
Conversation
Signed-off-by: timflannagan <[email protected]>
Related to #10496 |
@@ -261,7 +261,7 @@ func convertHeaderModifier(kctx krt.HandlerContext, f *gwv1.HTTPHeaderFilter) fu | |||
if f == nil { | |||
return nil | |||
} | |||
var headersToAddd []*envoy_config_core_v3.HeaderValueOption | |||
headersToAddd := make([]*envoy_config_core_v3.HeaderValueOption, 0, len(f.Add)+len(f.Set)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
headersToAddd := make([]*envoy_config_core_v3.HeaderValueOption, 0, len(f.Add)+len(f.Set)) | |
headersToAdd := make([]*envoy_config_core_v3.HeaderValueOption, 0, len(f.Add)+len(f.Set)) |
@@ -294,7 +294,7 @@ func convertResponseHeaderModifier(kctx krt.HandlerContext, f *gwv1.HTTPHeaderFi | |||
if f == nil { | |||
return nil | |||
} | |||
var headersToAddd []*envoy_config_core_v3.HeaderValueOption | |||
headersToAddd := make([]*envoy_config_core_v3.HeaderValueOption, 0, len(f.Add)+len(f.Set)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
headersToAddd := make([]*envoy_config_core_v3.HeaderValueOption, 0, len(f.Add)+len(f.Set)) | |
headersToAdd := make([]*envoy_config_core_v3.HeaderValueOption, 0, len(f.Add)+len(f.Set)) |
certs := make([][]byte, 0, len(s.secrets)) | ||
items := make([]cache_types.Resource, 0, len(s.secrets)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, the cap should be higher, looks like you can append to certs up to 4 times within each iteration, and append to items twice each iteration
@@ -51,7 +51,7 @@ func resourcesFromSnapshot(snap envoycache.ResourceSnapshot) (*EnvoyResources, e | |||
// listenersFromSnapshot accepts a Snapshot and extracts from it a slice of pointers to | |||
// the Listener structs contained in the Snapshot. | |||
func listenersFromSnapshot(snap envoycache.ResourceSnapshot) ([]*envoy_config_listener_v3.Listener, error) { | |||
var listeners []*envoy_config_listener_v3.Listener | |||
listeners := make([]*envoy_config_listener_v3.Listener, 0, len(snap.GetResources(envoyresource.ListenerType))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don't know how expensive the snap.GetResources call is, but should we just call it once and set it as a variable? (same with the other instances below)
Description
Enables the https://golangci-lint.run/usage/linters/#prealloc linter. We're relying on the
simple: true
default setting here. Any additional settings could overkill.Checklist: