소스 검색

refactor(processor): minor simplification of a loop

This makes the code a tad clearer.
jvoisin 1 년 전
부모
커밋
72486b9bd1
1개의 변경된 파일2개의 추가작업 그리고 3개의 파일을 삭제
  1. 2 3
      internal/reader/processor/processor.go

+ 2 - 3
internal/reader/processor/processor.go

@@ -7,6 +7,7 @@ import (
 	"log/slog"
 	"net/url"
 	"regexp"
+	"slices"
 	"time"
 
 	"github.com/tdewolff/minify/v2"
@@ -42,9 +43,7 @@ func ProcessFeedEntries(store *storage.Storage, feed *model.Feed, userID int64,
 	parsedSiteURL, _ := url.Parse(feed.SiteURL)
 
 	// Process older entries first
-	for i := len(feed.Entries) - 1; i >= 0; i-- {
-		entry := feed.Entries[i]
-
+	for _, entry := range slices.Backward(feed.Entries) {
 		slog.Debug("Processing entry",
 			slog.Int64("user_id", user.ID),
 			slog.String("entry_url", entry.URL),