mirror of
https://github.com/soypat/lneto.git
synced 2026-09-09 16:19:41 +00:00
Further reduce heap allocs (#56)
* work on tracking more heap allocations down * write own heapless IP AppendFormatAddr functions * remove potential Error method allocations * more logging
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package ipv4
|
||||
|
||||
import "strconv"
|
||||
|
||||
const (
|
||||
sizeHeader = 20
|
||||
)
|
||||
@@ -68,3 +70,15 @@ func b2u8(b bool) uint8 {
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// AppendFormatAddr appends the dotted-decimal text representation of an IPv4 address
|
||||
// to dst. Zero heap allocations.
|
||||
func AppendFormatAddr(dst []byte, addr [4]byte) []byte {
|
||||
for i, b := range addr {
|
||||
if i != 0 {
|
||||
dst = append(dst, '.')
|
||||
}
|
||||
dst = strconv.AppendUint(dst, uint64(b), 10)
|
||||
}
|
||||
return dst
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user