summaryrefslogtreecommitdiff
path: root/internal/db/bundb/notification.go
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2024-09-02 14:00:17 +0200
committerLibravatar GitHub <noreply@github.com>2024-09-02 14:00:17 +0200
commit25a815a8a438b19a5eafe4243093803129d4c49a (patch)
treed0515324b196927c69ff69c2bb4db66ac0e270ac /internal/db/bundb/notification.go
parent[chore]: Bump github.com/minio/minio-go/v7 from 7.0.75 to 7.0.76 (#3262) (diff)
downloadgotosocial-25a815a8a438b19a5eafe4243093803129d4c49a.tar.xz
[chore/performance] Avoid unnecessary "uncached" queries (#3265)
* [chore/performance] Avoid unnecessary "uncached" queries * go fmt
Diffstat (limited to 'internal/db/bundb/notification.go')
-rw-r--r--internal/db/bundb/notification.go8
1 files changed, 5 insertions, 3 deletions
diff --git a/internal/db/bundb/notification.go b/internal/db/bundb/notification.go
index 1103bb6a0..9959b160e 100644
--- a/internal/db/bundb/notification.go
+++ b/internal/db/bundb/notification.go
@@ -107,13 +107,15 @@ func (n *notificationDB) GetNotificationsByIDs(ctx context.Context, ids []string
notifs, err := n.state.Caches.DB.Notification.LoadIDs("ID",
ids,
func(uncached []string) ([]*gtsmodel.Notification, error) {
- // Skip query if everything was cached.
- if len(uncached) == 0 {
+ // Avoid querying
+ // if none uncached.
+ count := len(uncached)
+ if count == 0 {
return nil, nil
}
// Preallocate expected length of uncached notifications.
- notifs := make([]*gtsmodel.Notification, 0, len(uncached))
+ notifs := make([]*gtsmodel.Notification, 0, count)
// Perform database query scanning
// the remaining (uncached) IDs.