Skip to content

Commit

Permalink
chore: replace util.Min helper with built-in min (usememos#3224)
Browse files Browse the repository at this point in the history
  • Loading branch information
Juneezee authored Apr 13, 2024
1 parent cb7886d commit 3b550a8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
7 changes: 0 additions & 7 deletions internal/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,6 @@ func GenUUID() string {
return uuid.New().String()
}

func Min(x, y int) int {
if x < y {
return x
}
return y
}

var letters = []rune("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")

// RandomString returns a random string with length n.
Expand Down
5 changes: 2 additions & 3 deletions server/route/rss/rss.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"github.com/yourselfhosted/gomark/ast"
"github.com/yourselfhosted/gomark/renderer"

"github.com/usememos/memos/internal/util"
"github.com/usememos/memos/server/profile"
"github.com/usememos/memos/store"
)
Expand Down Expand Up @@ -102,7 +101,7 @@ func (s *RSSService) generateRSSFromMemoList(ctx context.Context, memoList []*st
Created: time.Now(),
}

var itemCountLimit = util.Min(len(memoList), maxRSSItemCount)
var itemCountLimit = min(len(memoList), maxRSSItemCount)
feed.Items = make([]*feeds.Item, itemCountLimit)
for i := 0; i < itemCountLimit; i++ {
memo := memoList[i]
Expand Down Expand Up @@ -152,7 +151,7 @@ func getRSSItemTitle(content string) string {
}

title := strings.Split(content, "\n")[0]
var titleLengthLimit = util.Min(len(title), maxRSSItemTitleLength)
var titleLengthLimit = min(len(title), maxRSSItemTitleLength)
if titleLengthLimit < len(title) {
title = title[:titleLengthLimit] + "..."
}
Expand Down

0 comments on commit 3b550a8

Please sign in to comment.