From 34a630808c737e7de58e85a3c82c63055c5da4da Mon Sep 17 00:00:00 2001 From: jvoisin Date: Wed, 18 Jun 2025 22:32:00 +0200 Subject: [PATCH] refactor(youtube): initiliaze two maps to the proper length --- internal/reader/processor/youtube.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/reader/processor/youtube.go b/internal/reader/processor/youtube.go index 51c5b860..c8996cb3 100644 --- a/internal/reader/processor/youtube.go +++ b/internal/reader/processor/youtube.go @@ -81,7 +81,7 @@ func fetchYouTubeWatchTimeForSingleEntry(websiteURL string) (int, error) { } func fetchYouTubeWatchTimeInBulk(entries []*model.Entry) { - var videosEntriesMapping = make(map[string]*model.Entry) + var videosEntriesMapping = make(map[string]*model.Entry, len(entries)) var videoIDs []string for _, entry := range entries { @@ -154,7 +154,7 @@ func fetchYouTubeWatchTimeFromApiInBulk(videoIDs []string) (map[string]time.Dura return nil, fmt.Errorf("youtube: unable to decode JSON: %v", err) } - watchTimeMap := make(map[string]time.Duration) + watchTimeMap := make(map[string]time.Duration, len(videos.Items)) for _, video := range videos.Items { duration, err := parseISO8601(video.ContentDetails.Duration) if err != nil {