mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-12 20:13:59 +02:00
Avoid calling strings.Fields multiple times with same content
This should be a relief for big sites.
This commit is contained in:
@@ -275,8 +275,7 @@ func TruncateWords(s string, max int) string {
|
||||
|
||||
// TruncateWordsToWholeSentence takes content and an int
|
||||
// and returns entire sentences from content, delimited by the int.
|
||||
func TruncateWordsToWholeSentence(s string, max int) string {
|
||||
words := strings.Fields(s)
|
||||
func TruncateWordsToWholeSentence(words []string, max int) string {
|
||||
if max > len(words) {
|
||||
return strings.Join(words, " ")
|
||||
}
|
||||
|
Reference in New Issue
Block a user