mirror of
https://github.com/soypat/lneto.git
synced 2026-07-26 10:38:47 +00:00
heap: remove heap alloc in pcap of HTTP content type; more debugging logs
This commit is contained in:
@@ -3,7 +3,6 @@ package httpraw
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"log/slog"
|
||||
"slices"
|
||||
"unsafe"
|
||||
|
||||
@@ -300,11 +299,13 @@ func (h *Header) appendHeader(key, value string) {
|
||||
if h.flags.hasAny(flagNoBufferGrow) {
|
||||
panic(errSmallBuffer)
|
||||
}
|
||||
debuglog("http:appendhdr:grow-buf")
|
||||
hb.buf = slices.Grow(buf, len(key)+len(value))
|
||||
}
|
||||
h.flags |= flagMangledBuffer
|
||||
k := hb.mustAppendSlice(key)
|
||||
v := hb.mustAppendSlice(value)
|
||||
debuglog("http:appendhdr:grow-hdrs")
|
||||
hb.headers = append(hb.headers, argsKV{
|
||||
key: k,
|
||||
value: v,
|
||||
@@ -426,10 +427,10 @@ func bytes2tok(buf, value []byte) headerSlice {
|
||||
}
|
||||
}
|
||||
|
||||
const enableDebug = false
|
||||
const enableDebug = internal.HeapAllocDebugging
|
||||
|
||||
func debuglog(msg string) {
|
||||
if enableDebug {
|
||||
internal.LogAttrs(nil, slog.LevelDebug, msg)
|
||||
internal.LogAllocs(msg)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user