avoid unneccesary OGDesc allocs

This commit is contained in:
Azareal 2020-03-15 12:00:29 +10:00
parent 8d19048c0d
commit 20ce00f434
1 changed files with 6 additions and 4 deletions

View File

@ -75,10 +75,12 @@ func ViewTopic(w http.ResponseWriter, r *http.Request, user c.User, header *c.He
} }
topic.ContentLines = strings.Count(topic.Content, "\n") topic.ContentLines = strings.Count(topic.Content, "\n")
if len(topic.Content) > 200 { if !user.Loggedin && user.LastAgent != c.Semrush {
header.OGDesc = topic.Content[:197] + "..." if len(topic.Content) > 200 {
} else { header.OGDesc = topic.Content[:197] + "..."
header.OGDesc = topic.Content } else {
header.OGDesc = topic.Content
}
} }
var parseSettings *c.ParseSettings var parseSettings *c.ParseSettings