diff options
Diffstat (limited to 'internal/db/bundb/mention.go')
-rw-r--r-- | internal/db/bundb/mention.go | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/internal/db/bundb/mention.go b/internal/db/bundb/mention.go index 877091296..e56300367 100644 --- a/internal/db/bundb/mention.go +++ b/internal/db/bundb/mention.go @@ -69,8 +69,15 @@ func (m *mentionDB) GetMentions(ctx context.Context, ids []string) ([]*gtsmodel. mentions, err := m.state.Caches.DB.Mention.LoadIDs("ID", ids, func(uncached []string) ([]*gtsmodel.Mention, error) { + // Avoid querying + // if none uncached. + count := len(uncached) + if count == 0 { + return nil, nil + } + // Preallocate expected length of uncached mentions. - mentions := make([]*gtsmodel.Mention, 0, len(uncached)) + mentions := make([]*gtsmodel.Mention, 0, count) // Perform database query scanning // the remaining (uncached) IDs. |