mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 21:38:05 -05:00
using slices.IndexFunc (#13834)
This commit is contained in:
@@ -20,6 +20,7 @@ package event
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"slices"
|
||||||
"sync"
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -219,12 +220,9 @@ type caseList []reflect.SelectCase
|
|||||||
|
|
||||||
// find returns the index of a case containing the given channel.
|
// find returns the index of a case containing the given channel.
|
||||||
func (cs caseList) find(channel interface{}) int {
|
func (cs caseList) find(channel interface{}) int {
|
||||||
for i, cas := range cs {
|
return slices.IndexFunc(cs, func(selectCase reflect.SelectCase) bool {
|
||||||
if cas.Chan.Interface() == channel {
|
return selectCase.Chan.Interface() == channel
|
||||||
return i
|
})
|
||||||
}
|
|
||||||
}
|
|
||||||
return -1
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// delete removes the given case from cs.
|
// delete removes the given case from cs.
|
||||||
|
|||||||
Reference in New Issue
Block a user