mirror of
https://github.com/soypat/lneto.git
synced 2026-08-22 07:29:04 +00:00
Add tcp.Listener (#15)
* begin reviewing TCP listener * begin adding listener tests * adding TestExchange implementation * split out legacy and Step tests * move listener to tcp package * fix up tcp tests taking very long * add xnet.TCPPool and work on TCPPool semantics * xnet: TCPPool only accepts established connections * xnet: getting to bottom of panic in xnet.Listener * xnet: improve listener tests * fix several data races in testing fixtures * fix more synchronization things in listener test * finalize tcplistener test
This commit is contained in:
@@ -67,3 +67,23 @@ func IsZeroed[T comparable](a ...T) bool {
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// DeleteZeroed deletes zero values in-place contained within the
|
||||
// slice and returns the modified slice without zero values.
|
||||
// Does not modify capacity.
|
||||
func DeleteZeroed[T comparable](a []T) []T {
|
||||
var z T
|
||||
off := 0
|
||||
deleted := false
|
||||
for i := 0; i < len(a); i++ {
|
||||
if a[i] != z {
|
||||
if deleted {
|
||||
a[off] = a[i]
|
||||
}
|
||||
off++
|
||||
} else if !deleted {
|
||||
deleted = true
|
||||
}
|
||||
}
|
||||
return a[:off]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user