From bf104cf952d93703b6d8ac858998bd93b1edc011 Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Tue, 23 Apr 2024 16:10:56 +0200 Subject: [PATCH] fix: drpb capacity --- delegated_translator.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/delegated_translator.go b/delegated_translator.go index d07a3ca..28bc9cd 100644 --- a/delegated_translator.go +++ b/delegated_translator.go @@ -112,7 +112,14 @@ func (dt *delegatedTranslator) find(w http.ResponseWriter, r *http.Request, encr // To make the Delegated Routing output nicer, deduplicate identical records. uniqueProviders := map[uint32]struct{}{} appendIfUnique := func(drp *drProvider) { - drpb := make([]byte, 0, len(drp.ID)+len(drp.Protocols)+len(drp.Schema)+len(drp.Metadata)) + capacity := len(drp.ID) + len(drp.Schema) + for _, proto := range drp.Protocols { + capacity += len(proto) + } + for _, meta := range drp.Metadata { + capacity += len(meta) + } + drpb := make([]byte, 0, capacity) drpb = append(drpb, []byte(drp.ID)...) for _, proto := range drp.Protocols { drpb = append(drpb, []byte(proto)...)