1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-22 10:18:38 +00: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:
KN4CK3R
2021-08-09 20:08:51 +02:00
committed by GitHub
parent 23d438f565
commit d9ef43a712
29 changed files with 183 additions and 302 deletions

View File

@@ -7,7 +7,6 @@ package templates
import (
"bytes"
"container/list"
"errors"
"fmt"
"html"
@@ -126,7 +125,6 @@ func NewFuncMap() []template.FuncMap {
},
"SizeFmt": base.FileSize,
"CountFmt": base.FormatNumberSI,
"List": List,
"SubStr": func(str string, start, length int) string {
if len(str) == 0 {
return ""
@@ -297,18 +295,6 @@ func NewFuncMap() []template.FuncMap {
},
"CommentMustAsDiff": gitdiff.CommentMustAsDiff,
"MirrorRemoteAddress": mirrorRemoteAddress,
"CommitType": func(commit interface{}) string {
switch commit.(type) {
case models.SignCommitWithStatuses:
return "SignCommitWithStatuses"
case models.SignCommit:
return "SignCommit"
case models.UserCommit:
return "UserCommit"
default:
return ""
}
},
"NotificationSettings": func() map[string]interface{} {
return map[string]interface{}{
"MinTimeout": int(setting.UI.Notification.MinTimeout / time.Millisecond),
@@ -428,7 +414,6 @@ func NewTextFuncMap() []texttmpl.FuncMap {
"DateFmtShort": func(t time.Time) string {
return t.Format("Jan 02, 2006")
},
"List": List,
"SubStr": func(str string, start, length int) string {
if len(str) == 0 {
return ""
@@ -636,20 +621,6 @@ func JSEscape(raw string) string {
return template.JSEscapeString(raw)
}
// List traversings the list
func List(l *list.List) chan interface{} {
e := l.Front()
c := make(chan interface{})
go func() {
for e != nil {
c <- e.Value
e = e.Next()
}
close(c)
}()
return c
}
// Sha1 returns sha1 sum of string
func Sha1(str string) string {
return base.EncodeSha1(str)