1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-08-16 18:01:37 +00:00

refactor: remove some fmt.Sprintf calls

fmt.Sprintf is slow, so let's get rid of it in trivial cases that are in (at
least) moderately hot paths.
This commit is contained in:
jvoisin 2025-08-08 22:55:35 +02:00 committed by Frédéric Guillot
parent 884521a7dd
commit 50c5996280
5 changed files with 30 additions and 28 deletions

View file

@ -67,7 +67,7 @@ func (f *FeedQueryBuilder) WithCounters() *FeedQueryBuilder {
// WithSorting add a sort expression.
func (f *FeedQueryBuilder) WithSorting(column, direction string) *FeedQueryBuilder {
f.sortExpressions = append(f.sortExpressions, fmt.Sprintf("%s %s", column, direction))
f.sortExpressions = append(f.sortExpressions, column+" "+direction)
return f
}
@ -95,7 +95,7 @@ func (f *FeedQueryBuilder) buildSorting() string {
var parts string
if len(f.sortExpressions) > 0 {
parts += fmt.Sprintf(" ORDER BY %s", strings.Join(f.sortExpressions, ", "))
parts += " ORDER BY " + strings.Join(f.sortExpressions, ", ")
}
if len(parts) > 0 {
@ -103,11 +103,11 @@ func (f *FeedQueryBuilder) buildSorting() string {
}
if f.limit > 0 {
parts += fmt.Sprintf(" LIMIT %d", f.limit)
parts += " LIMIT " + strconv.Itoa(f.limit)
}
if f.offset > 0 {
parts += fmt.Sprintf(" OFFSET %d", f.offset)
parts += " OFFSET " + strconv.Itoa(f.offset)
}
return parts