mirror of
1
Fork 0

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>
This commit is contained in:
Eng Zer Jun 2023-08-29 19:03:43 +08:00 committed by GitHub
parent db09b35590
commit ad3cbbc3b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 17 deletions

View File

@ -374,27 +374,25 @@ heaploop:
break heaploop break heaploop
} }
parentRemaining.Remove(current.CommitID) parentRemaining.Remove(current.CommitID)
if current.Paths != nil { for i, found := range current.Paths {
for i, found := range current.Paths { if !found {
if !found { continue
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 delete(path2idx, paths[i])
if results[i] == "" { remaining--
results[i] = current.CommitID if results[0] == "" {
if err := repo.LastCommitCache.Put(headRef, path.Join(treepath, paths[i]), current.CommitID); err != nil { results[0] = current.CommitID
if err := repo.LastCommitCache.Put(headRef, treepath, current.CommitID); err != nil {
return nil, err return nil, err
} }
delete(path2idx, paths[i]) delete(path2idx, "")
remaining-- 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--
}
} }
} }
} }