diff options
Diffstat (limited to 'internal/db/bundb/list.go')
-rw-r--r-- | internal/db/bundb/list.go | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/internal/db/bundb/list.go b/internal/db/bundb/list.go index 937257ef0..0ed0f1b15 100644 --- a/internal/db/bundb/list.go +++ b/internal/db/bundb/list.go @@ -353,8 +353,15 @@ func (l *listDB) GetListsByIDs(ctx context.Context, ids []string) ([]*gtsmodel.L lists, err := l.state.Caches.DB.List.LoadIDs("ID", ids, func(uncached []string) ([]*gtsmodel.List, error) { + // Avoid querying + // if none uncached. + count := len(uncached) + if count == 0 { + return nil, nil + } + // Preallocate expected length of uncached lists. - lists := make([]*gtsmodel.List, 0, len(uncached)) + lists := make([]*gtsmodel.List, 0, count) // Perform database query scanning // the remaining (uncached) IDs. @@ -400,8 +407,15 @@ func (l *listDB) GetListEntriesByIDs(ctx context.Context, ids []string) ([]*gtsm entries, err := l.state.Caches.DB.ListEntry.LoadIDs("ID", ids, func(uncached []string) ([]*gtsmodel.ListEntry, error) { + // Avoid querying + // if none uncached. + count := len(uncached) + if count == 0 { + return nil, nil + } + // Preallocate expected length of uncached entries. - entries := make([]*gtsmodel.ListEntry, 0, len(uncached)) + entries := make([]*gtsmodel.ListEntry, 0, count) // Perform database query scanning // the remaining (uncached) IDs. |