diff options
Diffstat (limited to 'internal/db/bundb/statusbookmark.go')
-rw-r--r-- | internal/db/bundb/statusbookmark.go | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/internal/db/bundb/statusbookmark.go b/internal/db/bundb/statusbookmark.go index 93a14610f..87fb17351 100644 --- a/internal/db/bundb/statusbookmark.go +++ b/internal/db/bundb/statusbookmark.go @@ -73,8 +73,15 @@ func (s *statusBookmarkDB) GetStatusBookmarksByIDs(ctx context.Context, ids []st bookmarks, err := s.state.Caches.DB.StatusBookmark.LoadIDs("ID", ids, func(uncached []string) ([]*gtsmodel.StatusBookmark, error) { + // Avoid querying + // if none uncached. + count := len(uncached) + if count == 0 { + return nil, nil + } + // Preallocate expected length of uncached bookmarks. - bookmarks := make([]*gtsmodel.StatusBookmark, 0, len(uncached)) + bookmarks := make([]*gtsmodel.StatusBookmark, 0, count) // Perform database query scanning // the remaining (uncached) bookmarks. |