Skip to content

Commit

Permalink
fix: drpb capacity
Browse files Browse the repository at this point in the history
  • Loading branch information
hacdias authored and masih committed Apr 23, 2024
1 parent 8f5c283 commit bf104cf
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion delegated_translator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)...)
Expand Down

0 comments on commit bf104cf

Please sign in to comment.