mirror of
https://codeberg.org/davrot/forgejo.git
synced 2025-05-28 12:00:01 +02:00
Replace list.List
with slices (#16311)
* Replaced list with slice. * Fixed usage of pointer to temporary variable. * Replaced LIFO list with slice. * Lint * Removed type check. * Removed duplicated code. * Lint * Fixed merge. Co-authored-by: 6543 <6543@obermui.de>
This commit is contained in:
parent
23d438f565
commit
d9ef43a712
29 changed files with 183 additions and 302 deletions
|
@ -1211,7 +1211,7 @@ func GetPullRequestCommits(ctx *context.APIContext) {
|
|||
|
||||
listOptions := utils.GetListOptions(ctx)
|
||||
|
||||
totalNumberOfCommits := commits.Len()
|
||||
totalNumberOfCommits := len(commits)
|
||||
totalNumberOfPages := int(math.Ceil(float64(totalNumberOfCommits) / float64(listOptions.PageSize)))
|
||||
|
||||
userCache := make(map[string]*models.User)
|
||||
|
@ -1222,29 +1222,14 @@ func GetPullRequestCommits(ctx *context.APIContext) {
|
|||
end = totalNumberOfCommits
|
||||
}
|
||||
|
||||
apiCommits := make([]*api.Commit, end-start)
|
||||
|
||||
i := 0
|
||||
addedCommitsCount := 0
|
||||
for commitPointer := commits.Front(); commitPointer != nil; commitPointer = commitPointer.Next() {
|
||||
if i < start {
|
||||
i++
|
||||
continue
|
||||
}
|
||||
if i >= end {
|
||||
break
|
||||
}
|
||||
|
||||
commit := commitPointer.Value.(*git.Commit)
|
||||
|
||||
// Create json struct
|
||||
apiCommits[addedCommitsCount], err = convert.ToCommit(ctx.Repo.Repository, commit, userCache)
|
||||
addedCommitsCount++
|
||||
apiCommits := make([]*api.Commit, 0, end-start)
|
||||
for i := start; i < end; i++ {
|
||||
apiCommit, err := convert.ToCommit(ctx.Repo.Repository, commits[i], userCache)
|
||||
if err != nil {
|
||||
ctx.ServerError("toCommit", err)
|
||||
return
|
||||
}
|
||||
i++
|
||||
apiCommits = append(apiCommits, apiCommit)
|
||||
}
|
||||
|
||||
ctx.SetLinkHeader(int(totalNumberOfCommits), listOptions.PageSize)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue