Skip to content

Commit 1c732ef

Browse files
committed
markup: microoptimise for many short filenames in directory
Move strings.ToLower() after the early-return length check. This is a safe operation in all cases and should slightly improve directory listing performance when a directory contains many thousands of files with short filenames.
1 parent 930d175 commit 1c732ef

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

modules/markup/markup.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,14 @@ func ReadmeFileType(name string) (string, bool) {
7171
// IsReadmeFile reports whether name looks like a README file
7272
// based on its name.
7373
func IsReadmeFile(name string) bool {
74-
name = strings.ToLower(name)
7574
if len(name) < 6 {
7675
return false
77-
} else if len(name) == 6 {
76+
}
77+
78+
name = strings.ToLower(name)
79+
if len(name) == 6 {
7880
return name == "readme"
7981
}
8082
return name[:7] == "readme."
8183
}
84+

0 commit comments

Comments
 (0)