From 616db41eadb85e7644468362d65dbdce26e27823 Mon Sep 17 00:00:00 2001 From: Laptop Date: Sat, 21 Dec 2024 20:48:42 +0200 Subject: [PATCH] restream: increase default parts list capacity allocation (16 => 24) --- lib/restream/init.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/restream/init.go b/lib/restream/init.go index a4b9ebc..2bf2a32 100644 --- a/lib/restream/init.go +++ b/lib/restream/init.go @@ -20,6 +20,8 @@ var httpc *fasthttp.HostClient var httpc_aac *fasthttp.HostClient var httpc_image *fasthttp.HostClient +const defaultPartsCapacity = 24 + type reader struct { parts [][]byte leftover []byte @@ -72,7 +74,7 @@ func (r *reader) Setup(url string, aac bool) error { if r.parts == nil { cfg.Log("make() r.parts") - r.parts = make([][]byte, 0, 16) + r.parts = make([][]byte, 0, defaultPartsCapacity) } else { cfg.Log(cap(r.parts), len(r.parts)) } @@ -310,7 +312,7 @@ func Load(r fiber.Router) { data = resp.Body() } - parts := make([][]byte, 0, 16) + parts := make([][]byte, 0, defaultPartsCapacity) for _, s := range bytes.Split(data, []byte{'\n'}) { if len(s) == 0 || s[0] == '#' { continue @@ -389,7 +391,7 @@ func Load(r fiber.Router) { data = resp.Body() } - parts := make([][]byte, 0, 16) + parts := make([][]byte, 0, defaultPartsCapacity) // clone needed to mitigate memory skill issues here for _, s := range bytes.Split(data, []byte{'\n'}) { if len(s) == 0 {