Skip to content

Commit 4bfbdd2

Browse files
committed
event: using slices.Index in std lib
1 parent 3ff99ae commit 4bfbdd2

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

event/event.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"errors"
2222
"fmt"
2323
"reflect"
24+
"slices"
2425
"sync"
2526
"time"
2627
)
@@ -66,7 +67,7 @@ func (mux *TypeMux) Subscribe(types ...interface{}) *TypeMuxSubscription {
6667
for _, t := range types {
6768
rtyp := reflect.TypeOf(t)
6869
oldsubs := mux.subm[rtyp]
69-
if find(oldsubs, sub) != -1 {
70+
if slices.Index(oldsubs, sub) != -1 {
7071
panic(fmt.Sprintf("event: duplicate type %s in Subscribe", rtyp))
7172
}
7273
subs := make([]*TypeMuxSubscription, len(oldsubs)+1)
@@ -118,7 +119,7 @@ func (mux *TypeMux) del(s *TypeMuxSubscription) {
118119
mux.mutex.Lock()
119120
defer mux.mutex.Unlock()
120121
for typ, subs := range mux.subm {
121-
if pos := find(subs, s); pos >= 0 {
122+
if pos := slices.Index(subs, s); pos >= 0 {
122123
if len(subs) == 1 {
123124
delete(mux.subm, typ)
124125
} else {

0 commit comments

Comments
 (0)