mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-24 05:36:46 +00:00
event: refactor to use slices.Delete in golang std lib
This commit is contained in:
parent
cbbf686ecc
commit
c2f0df8372
1 changed files with 2 additions and 8 deletions
|
|
@ -21,6 +21,7 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"slices"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
@ -122,7 +123,7 @@ func (mux *TypeMux) del(s *TypeMuxSubscription) {
|
||||||
if len(subs) == 1 {
|
if len(subs) == 1 {
|
||||||
delete(mux.subm, typ)
|
delete(mux.subm, typ)
|
||||||
} else {
|
} else {
|
||||||
mux.subm[typ] = posdelete(subs, pos)
|
mux.subm[typ] = slices.Delete(slices.Clone(subs), pos, pos+1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -137,13 +138,6 @@ func find(slice []*TypeMuxSubscription, item *TypeMuxSubscription) int {
|
||||||
return -1
|
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.
|
// TypeMuxSubscription is a subscription established through TypeMux.
|
||||||
type TypeMuxSubscription struct {
|
type TypeMuxSubscription struct {
|
||||||
mux *TypeMux
|
mux *TypeMux
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue