Skip to content

Commit

Permalink
Use slices.DeleteFunc
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoPolo committed Aug 23, 2024
1 parent 4345acc commit c96307c
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions p2p/transport/webtransport/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"net"
"net/http"
"slices"
"time"

"github.com/libp2p/go-libp2p/core/network"
Expand Down Expand Up @@ -301,12 +302,9 @@ loop:
}

l.transport.listenersMu.Lock()
for i, ln := range l.transport.listeners {
if ln == l {
l.transport.listeners = append(l.transport.listeners[:i], l.transport.listeners[i+1:]...)
break
}
}
l.transport.listeners = slices.DeleteFunc(l.transport.listeners, func(ln *listener) bool {
return ln == l
})
l.transport.listenersMu.Unlock()

return err
Expand Down

0 comments on commit c96307c

Please sign in to comment.