mirror of
https://github.com/soypat/lneto.git
synced 2026-08-30 19:39:05 +00:00
do not rely on unspecified Go behaviour; fix TCP ring buffer bug (#16)
* do not rely on unspecified Go behaviour; fix TCP ring buffer bug * even more stricter error handling on tcp connections * stricter lock copying in tcp.Conn, even though likely not a problem * add listener and tcp pool logging * forgot reqAddr unused * add logging to TCPConn and friends
This commit is contained in:
@@ -56,34 +56,3 @@ func SetIPAddrs(buf []byte, id uint16, src, dst []byte) (err error) {
|
||||
copy(dstaddr, dst)
|
||||
return nil
|
||||
}
|
||||
|
||||
// IsZeroed returns true if all arguments are set to their zero value.
|
||||
func IsZeroed[T comparable](a ...T) bool {
|
||||
var z T
|
||||
for i := range a {
|
||||
if a[i] != z {
|
||||
return false
|
||||
}
|
||||
}
|
||||
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