aboutsummaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorEng Zer Jun <engzerjun@gmail.com>2023-08-29 19:03:43 +0800
committerGitHub <noreply@github.com>2023-08-29 11:03:43 +0000
commitad3cbbc3b1ce80c22d439848c41a926280521344 (patch)
tree71e65137d6acbc60c17a14e9aa2d8c9cfc115bde /modules
parentdb09b35590758b62ec8764718dff8a854749bcfb (diff)
downloadgitea-ad3cbbc3b1ce80c22d439848c41a926280521344.tar.gz
gitea-ad3cbbc3b1ce80c22d439848c41a926280521344.zip
Remove redundant nil check in `WalkGitLog` (#26773)
From the Go specification: > "1. For a nil slice, the number of iterations is 0." https://go.dev/ref/spec#For_range Therefore, an additional nil check for before the loop is unnecessary. Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
Diffstat (limited to 'modules')
-rw-r--r--modules/git/log_name_status.go32
1 files changed, 15 insertions, 17 deletions
diff --git a/modules/git/log_name_status.go b/modules/git/log_name_status.go
index 70f6ef9dbb..7519e32b90 100644
--- a/modules/git/log_name_status.go
+++ b/modules/git/log_name_status.go
@@ -374,27 +374,25 @@ heaploop:
break heaploop
}
parentRemaining.Remove(current.CommitID)
- if current.Paths != nil {
- for i, found := range current.Paths {
- if !found {
- continue
+ for i, found := range current.Paths {
+ if !found {
+ continue
+ }
+ changed[i] = false
+ if results[i] == "" {
+ results[i] = current.CommitID
+ if err := repo.LastCommitCache.Put(headRef, path.Join(treepath, paths[i]), current.CommitID); err != nil {
+ return nil, err
}
- changed[i] = false
- if results[i] == "" {
- results[i] = current.CommitID
- if err := repo.LastCommitCache.Put(headRef, path.Join(treepath, paths[i]), current.CommitID); err != nil {
+ delete(path2idx, paths[i])
+ remaining--
+ if results[0] == "" {
+ results[0] = current.CommitID
+ if err := repo.LastCommitCache.Put(headRef, treepath, current.CommitID); err != nil {
return nil, err
}
- delete(path2idx, paths[i])
+ delete(path2idx, "")
remaining--
- if results[0] == "" {
- results[0] = current.CommitID
- if err := repo.LastCommitCache.Put(headRef, treepath, current.CommitID); err != nil {
- return nil, err
- }
- delete(path2idx, "")
- remaining--
- }
}
}
}