Skip to content

Commit a5a2e00

Browse files
committed
Don't use NormalEOF when unnecessary
1 parent 5305005 commit a5a2e00

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

models/repo_generate.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@
55
package models
66

77
import (
8+
"bufio"
9+
"bytes"
810
"strconv"
911
"strings"
1012

1113
"code.gitea.io/gitea/modules/git"
1214
"code.gitea.io/gitea/modules/log"
1315
"code.gitea.io/gitea/modules/storage"
14-
"code.gitea.io/gitea/modules/util"
1516

1617
"github.com/gobwas/glob"
1718
)
@@ -49,9 +50,9 @@ func (gt GiteaTemplate) Globs() []glob.Glob {
4950
}
5051

5152
gt.globs = make([]glob.Glob, 0)
52-
lines := strings.Split(string(util.NormalizeEOL(gt.Content)), "\n")
53-
for _, line := range lines {
54-
line = strings.TrimSpace(line)
53+
scanner := bufio.NewScanner(bytes.NewReader(gt.Content))
54+
for scanner.Scan() {
55+
line := strings.TrimSpace(scanner.Text())
5556
if line == "" || strings.HasPrefix(line, "#") {
5657
continue
5758
}

modules/markup/markdown/markdown.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import (
1616
"code.gitea.io/gitea/modules/markup"
1717
"code.gitea.io/gitea/modules/markup/common"
1818
"code.gitea.io/gitea/modules/setting"
19-
giteautil "code.gitea.io/gitea/modules/util"
2019

2120
chromahtml "github.com/alecthomas/chroma/formatters/html"
2221
"github.com/yuin/goldmark"
@@ -170,7 +169,7 @@ func actualRender(ctx *markup.RenderContext, input io.Reader, output io.Writer)
170169
limit: setting.UI.MaxDisplayFileSize * 3,
171170
}
172171

173-
// FIXME: should we include a timeout that closes the pipe to abort the parser and sanitizer if it takes too long?
172+
// FIXME: should we include a timeout that closes the pipe to abort the renderer and sanitizer if it takes too long?
174173
go func() {
175174
defer func() {
176175
err := recover()
@@ -187,7 +186,7 @@ func actualRender(ctx *markup.RenderContext, input io.Reader, output io.Writer)
187186

188187
// FIXME: Don't read all to memory, but goldmark doesn't support
189188
pc := NewGiteaParseContext(ctx)
190-
buf, err := ioutil.ReadAll(giteautil.NormalizeEOLReader(input))
189+
buf, err := ioutil.ReadAll(input)
191190
if err != nil {
192191
log.Error("Unable to ReadAll: %v", err)
193192
return

0 commit comments

Comments
 (0)