summaryrefslogtreecommitdiffstats
path: root/routers/web/repo/blame.go
diff options
context:
space:
mode:
authorKN4CK3R <admin@oldschoolhack.me>2021-08-09 20:08:51 +0200
committerGitHub <noreply@github.com>2021-08-09 14:08:51 -0400
commitd9ef43a7126ab83af563c1c9b54cdf0092327b2a (patch)
treefabc9a9d24d42bb0de6dd9557c9e07e95bd5722b /routers/web/repo/blame.go
parent23d438f56524a7c3fc185df66d6d95f797a80eee (diff)
downloadgitea-d9ef43a7126ab83af563c1c9b54cdf0092327b2a.tar.gz
gitea-d9ef43a7126ab83af563c1c9b54cdf0092327b2a.zip
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>
Diffstat (limited to 'routers/web/repo/blame.go')
-rw-r--r--routers/web/repo/blame.go17
1 files changed, 6 insertions, 11 deletions
diff --git a/routers/web/repo/blame.go b/routers/web/repo/blame.go
index 4ade9e9a93..c2da8e9cdc 100644
--- a/routers/web/repo/blame.go
+++ b/routers/web/repo/blame.go
@@ -5,7 +5,6 @@
package repo
import (
- "container/list"
"fmt"
"html"
gotemplate "html/template"
@@ -138,15 +137,15 @@ func RefBlame(ctx *context.Context) {
ctx.HTML(http.StatusOK, tplBlame)
}
-func processBlameParts(ctx *context.Context, blameParts []git.BlamePart) (map[string]models.UserCommit, map[string]string) {
+func processBlameParts(ctx *context.Context, blameParts []git.BlamePart) (map[string]*models.UserCommit, map[string]string) {
// store commit data by SHA to look up avatar info etc
- commitNames := make(map[string]models.UserCommit)
+ commitNames := make(map[string]*models.UserCommit)
// previousCommits contains links from SHA to parent SHA,
// if parent also contains the current TreePath.
previousCommits := make(map[string]string)
// and as blameParts can reference the same commits multiple
// times, we cache the lookup work locally
- commits := list.New()
+ commits := make([]*git.Commit, 0, len(blameParts))
commitCache := map[string]*git.Commit{}
commitCache[ctx.Repo.Commit.ID.String()] = ctx.Repo.Commit
@@ -190,22 +189,18 @@ func processBlameParts(ctx *context.Context, blameParts []git.BlamePart) (map[st
}
}
- commits.PushBack(commit)
-
- commitNames[commit.ID.String()] = models.UserCommit{}
+ commits = append(commits, commit)
}
// populate commit email addresses to later look up avatars.
- commits = models.ValidateCommitsWithEmails(commits)
- for e := commits.Front(); e != nil; e = e.Next() {
- c := e.Value.(models.UserCommit)
+ for _, c := range models.ValidateCommitsWithEmails(commits) {
commitNames[c.ID.String()] = c
}
return commitNames, previousCommits
}
-func renderBlame(ctx *context.Context, blameParts []git.BlamePart, commitNames map[string]models.UserCommit, previousCommits map[string]string) {
+func renderBlame(ctx *context.Context, blameParts []git.BlamePart, commitNames map[string]*models.UserCommit, previousCommits map[string]string) {
repoLink := ctx.Repo.RepoLink
var lines = make([]string, 0)