Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions event/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"errors"
"fmt"
"reflect"
"slices"
"sync"
"time"
)
Expand Down Expand Up @@ -122,7 +123,7 @@ func (mux *TypeMux) del(s *TypeMuxSubscription) {
if len(subs) == 1 {
delete(mux.subm, typ)
} else {
mux.subm[typ] = posdelete(subs, pos)
mux.subm[typ] = slices.Delete(slices.Clone(subs), pos, pos+1)
}
}
}
Expand All @@ -137,13 +138,6 @@ func find(slice []*TypeMuxSubscription, item *TypeMuxSubscription) int {
return -1
}

func posdelete(slice []*TypeMuxSubscription, pos int) []*TypeMuxSubscription {
news := make([]*TypeMuxSubscription, len(slice)-1)
copy(news[:pos], slice[:pos])
copy(news[pos:], slice[pos+1:])
return news
}

// TypeMuxSubscription is a subscription established through TypeMux.
type TypeMuxSubscription struct {
mux *TypeMux
Expand Down