forked from kevadesu/forgejo
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
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue