From ea411e5febe07eee06c9d84be30e58a1cb56f75b Mon Sep 17 00:00:00 2001 From: mkelvers Date: Sat, 13 Jun 2026 21:30:49 +0200 Subject: [PATCH] perf: preallocate fetchedAnimes in fetchBaselineAnime --- integrations/jikan/seasons.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/integrations/jikan/seasons.go b/integrations/jikan/seasons.go index cdaa0a2..8dc7ae1 100644 --- a/integrations/jikan/seasons.go +++ b/integrations/jikan/seasons.go @@ -115,10 +115,14 @@ func (c *Client) seedRandomPoolBaseline() { } func (c *Client) fetchBaselineAnime(ctx context.Context) []Anime { - fetchedAnimes := make([]Anime, 0) - fetchedAnimes = append(fetchedAnimes, c.fetchTopAnimePage(ctx, 1)...) - fetchedAnimes = append(fetchedAnimes, c.fetchTopAnimePage(ctx, 2)...) - fetchedAnimes = append(fetchedAnimes, c.fetchCurrentSeasonAnime(ctx)...) + topPageOne := c.fetchTopAnimePage(ctx, 1) + topPageTwo := c.fetchTopAnimePage(ctx, 2) + currentSeason := c.fetchCurrentSeasonAnime(ctx) + + fetchedAnimes := make([]Anime, 0, len(topPageOne)+len(topPageTwo)+len(currentSeason)) + fetchedAnimes = append(fetchedAnimes, topPageOne...) + fetchedAnimes = append(fetchedAnimes, topPageTwo...) + fetchedAnimes = append(fetchedAnimes, currentSeason...) return fetchedAnimes }