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:
parent
884521a7dd
commit
50c5996280
5 changed files with 30 additions and 28 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue