mirror of
https://github.com/soypat/lneto.git
synced 2026-09-10 08:39:30 +00:00
Reduce heap allocs 2 (#46)
* reduce heap allocations in tcp logging; omit use of AppendFloat which allocates a metric sh*tton * debugheaplog: better heap statistic logging * heap: use string for pcap.Frame.Protocol * add potential to eliminate Flags.String heap alloc, remove incorrect HEAP comments * add StackAsync.DebugErr and httpraw.SetBytes * many heap alloc reductions and replacement of bytes.Equal with internal.BytesEqual
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
package ltesto
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"math"
|
||||
"math/rand"
|
||||
|
||||
"github.com/soypat/lneto"
|
||||
"github.com/soypat/lneto/ethernet"
|
||||
"github.com/soypat/lneto/internal"
|
||||
"github.com/soypat/lneto/ipv4"
|
||||
"github.com/soypat/lneto/ipv4/icmpv4"
|
||||
"github.com/soypat/lneto/tcp"
|
||||
@@ -134,9 +134,9 @@ func (gen *PacketGen) AppendRandomIPv4TCPPacket(dst []byte, rng *rand.Rand, seg
|
||||
switch {
|
||||
case gen.SrcTCP != tfrm.SourcePort():
|
||||
panic("IP options overwrite TCP header")
|
||||
case !bytes.Equal(ifrm.Options(), ipOpts):
|
||||
case !internal.BytesEqual(ifrm.Options(), ipOpts):
|
||||
panic("bad ip options written, ensure ip options length is multiple of 4")
|
||||
case !bytes.Equal(tfrm.Options(), tcpOpts):
|
||||
case !internal.BytesEqual(tfrm.Options(), tcpOpts):
|
||||
panic("bad tcp options written, ensure tcp options length is multiple of 4")
|
||||
case *ifrm.DestinationAddr() != gen.DstIPv4:
|
||||
panic("IP options overwrite own header")
|
||||
|
||||
Reference in New Issue
Block a user