Skip to content

Commit

Permalink
chore: avoid unnecessary alloc
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>
  • Loading branch information
crenshaw-dev committed Dec 10, 2024
1 parent 2f51067 commit fd155da
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion controller/appcontroller.go
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,11 @@ func (projCache *appProjCache) GetAppProject(ctx context.Context) (*appv1.AppPro

// getAppProj gets the AppProject for the given Application app.
func (ctrl *ApplicationController) getAppProj(app *appv1.Application) (*appv1.AppProject, error) {
projCache, _ := ctrl.projByNameCache.LoadOrStore(app.Spec.GetProject(), ctrl.newAppProjCache(app.Spec.GetProject()))
projCache, _ := ctrl.projByNameCache.Load(app.Spec.GetProject())
if projCache == nil {
projCache = ctrl.newAppProjCache(app.Spec.GetProject())
ctrl.projByNameCache.Store(app.Spec.GetProject(), projCache)
}
proj, err := projCache.(*appProjCache).GetAppProject(context.TODO())
if err != nil {
if apierr.IsNotFound(err) {
Expand Down

0 comments on commit fd155da

Please sign in to comment.