From 397e8fd65b90680bb9514bc6eac4e877e89db3a3 Mon Sep 17 00:00:00 2001 From: David Robertson Date: Tue, 11 Jul 2023 19:57:53 +0100 Subject: [PATCH] Ensure NID slices are never nil --- state/event_table.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/state/event_table.go b/state/event_table.go index c4a348d9..c9d41a04 100644 --- a/state/event_table.go +++ b/state/event_table.go @@ -84,7 +84,12 @@ func (ev *Event) ensureFieldsSetOnEvent() error { type StrippedEvents []Event +// NIDs partitions the nids in this set of stripped events into the nids of membership +// events and all others. The returned lists inherit their order from the given slice of +// StrippedEvents, and are never nil. func (se StrippedEvents) NIDs() (membershipNIDs, otherNIDs []int64) { + membershipNIDs = make([]int64, 0, len(se)) + otherNIDs = make([]int64, 0, len(se)) for _, s := range se { if s.Type == "m.room.member" { membershipNIDs = append(membershipNIDs, s.NID)