Skip to content

Commit

Permalink
perf(youtube): Grow slice before appending items
Browse files Browse the repository at this point in the history
  • Loading branch information
gabe565 committed Jun 19, 2024
1 parent 1727660 commit 1e72f4e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion internal/youtube/playlist/playlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"errors"
"fmt"
"net/url"
"slices"
"sort"
"time"

Expand Down Expand Up @@ -79,9 +80,10 @@ func (p Playlist) Items() ([]*Item, error) {
call.PlaylistId(p.ID)
limit := 200

items := make([]*Item, 0)
var items []*Item
i := 0
err := call.Pages(p.Context, func(response *youtube.PlaylistItemListResponse) error {
items = slices.Grow(items, len(response.Items))
for _, item := range response.Items {
if item.Status.PrivacyStatus == "private" {
continue
Expand Down

0 comments on commit 1e72f4e

Please sign in to comment.