Skip to content

Commit

Permalink
preallocate the modifiedAuthConfigs slice
Browse files Browse the repository at this point in the history
Signed-off-by: Guilherme Cassolato <guicassolato@gmail.com>
  • Loading branch information
guicassolato committed Nov 4, 2024
1 parent 189f783 commit 3401dbc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ linters:
- revive
- gosec
- stylecheck
- prealloc
- tparallel
- unconvert
- unparam
- whitespace
- goimports
disable:
- errcheck
- prealloc

issues:
exclude-rules:
Expand Down
6 changes: 4 additions & 2 deletions controllers/authconfigs_reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (r *AuthConfigsReconciler) Reconcile(ctx context.Context, _ []controller.Re
defer logger.V(1).Info("finished reconciling authconfig objects")

desiredAuthConfigs := make(map[k8stypes.NamespacedName]struct{})
var modifiedAuthConfigs []string
modifiedAuthConfigs := []string{}

for pathID, effectivePolicy := range effectivePoliciesMap {
_, _, _, httpRoute, httpRouteRule, _ := common.ObjectsInRequestPath(effectivePolicy.Path)
Expand Down Expand Up @@ -130,7 +130,9 @@ func (r *AuthConfigsReconciler) Reconcile(ctx context.Context, _ []controller.Re
}
}

state.Store(StateModifiedAuthConfigs, modifiedAuthConfigs)
if len(modifiedAuthConfigs) > 0 {
state.Store(StateModifiedAuthConfigs, modifiedAuthConfigs)
}

// cleanup authconfigs that are not in the effective policies
staleAuthConfigs := topology.Objects().Items(func(o machinery.Object) bool {
Expand Down

0 comments on commit 3401dbc

Please sign in to comment.