From 1e1d8a8fcd304c7fa0d7d75d5cbcfa429eeb8d2d Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Mon, 7 Sep 2026 18:25:04 +0200 Subject: [PATCH] Collect the current branches of the recent repos in a slice Nothing needs to look up the branch of a repo by its path, so a slice indexed like the list of paths does the job, and its elements are plain strings instead of the values of type "any" that a sync.Map hands back. The next commits measure and truncate the branch name, which needs a string. Co-authored-by: Claude Opus 5 (1M context) --- pkg/gui/controllers/helpers/repos_helper.go | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/pkg/gui/controllers/helpers/repos_helper.go b/pkg/gui/controllers/helpers/repos_helper.go index c8a33bcbe..1fb8588e7 100644 --- a/pkg/gui/controllers/helpers/repos_helper.go +++ b/pkg/gui/controllers/helpers/repos_helper.go @@ -2,7 +2,6 @@ package helpers import ( "errors" - "fmt" "os" "path/filepath" "strings" @@ -112,24 +111,24 @@ func (self *ReposHelper) CreateRecentReposMenu() error { recentRepoPaths = self.c.GetAppState().RecentRepos[1:] } - currentBranches := sync.Map{} + currentBranches := make([]string, len(recentRepoPaths)) wg := sync.WaitGroup{} wg.Add(len(recentRepoPaths)) - for _, path := range recentRepoPaths { - go func(path string) { + for i, path := range recentRepoPaths { + go func() { defer wg.Done() - currentBranches.Store(path, self.getCurrentBranch(path)) - }(path) + currentBranches[i] = self.getCurrentBranch(path) + }() } wg.Wait() - menuItems := lo.Map(recentRepoPaths, func(path string, _ int) *types.MenuItem { - branchName, _ := currentBranches.Load(path) + menuItems := lo.Map(recentRepoPaths, func(path string, i int) *types.MenuItem { + branchName := currentBranches[i] if icons.IsIconEnabled() { - branchName = icons.BRANCH_ICON + " " + fmt.Sprintf("%v", branchName) + branchName = icons.BRANCH_ICON + " " + branchName } return &types.MenuItem{