perf: preallocate fetchedAnimes in fetchBaselineAnime

This commit is contained in:
2026-06-13 21:30:49 +02:00
parent aced7bb5d9
commit ea411e5feb

View File

@@ -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
}