]> Cypherpunks.ru repositories - gostls13.git/commitdiff
runtime/pprof: set labelMap length
authorSasha Melentyev <sasha@melentyev.io>
Sat, 3 Sep 2022 18:56:43 +0000 (18:56 +0000)
committerGopher Robot <gobot@golang.org>
Mon, 19 Sep 2022 16:58:39 +0000 (16:58 +0000)
Change-Id: If09094e72161f2c5da9102706781524e32f87782
GitHub-Last-Rev: 89949bc6ee8622be31c4e4db45ea6da11fd9053f
GitHub-Pull-Request: golang/go#54855
Reviewed-on: https://go-review.googlesource.com/c/go/+/428234
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
src/runtime/pprof/label.go

index 0c58a7ac47e5a05857be2e0ff5bba0ba3dce6c88..d39e0ad58e21d0bc6bd60d36621d78d1ca5fa91e 100644 (file)
@@ -57,8 +57,8 @@ func (l *labelMap) String() string {
 // WithLabels returns a new context.Context with the given labels added.
 // A label overwrites a prior label with the same key.
 func WithLabels(ctx context.Context, labels LabelSet) context.Context {
-       childLabels := make(labelMap)
        parentLabels := labelValue(ctx)
+       childLabels := make(labelMap, len(parentLabels))
        // TODO(matloob): replace the map implementation with something
        // more efficient so creating a child context WithLabels doesn't need
        // to clone the map.