Skip to content

Commit

Permalink
Ensure NID slices are never nil
Browse files Browse the repository at this point in the history
  • Loading branch information
David Robertson committed Jul 11, 2023
1 parent 73d0c60 commit 397e8fd
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions state/event_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 397e8fd

Please sign in to comment.