heap: remove heap alloc in pcap of HTTP content type; more debugging logs

This commit is contained in:
Patricio Whittingslow
2026-02-28 17:46:08 -03:00
parent 4f7635b216
commit f6e7801d8c
5 changed files with 40 additions and 26 deletions
+4 -3
View File
@@ -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)
}
}