]> Cypherpunks.ru repositories - gostls13.git/blobdiff - src/runtime/pprof/label.go
runtime: add available godoc link
[gostls13.git] / src / runtime / pprof / label.go
index b614f1254491e2b1fa3312ea9abb1cf06ac6d031..3684ae34e51cfcd8dac0306dff15bb2a5cadd061 100644 (file)
@@ -37,7 +37,7 @@ func labelValue(ctx context.Context) labelMap {
 // that admits incremental immutable modification more efficiently.
 type labelMap map[string]string
 
-// String statisfies Stringer and returns key, value pairs in a consistent
+// String satisfies Stringer and returns key, value pairs in a consistent
 // order.
 func (l *labelMap) String() string {
        if l == nil {
@@ -54,11 +54,11 @@ func (l *labelMap) String() string {
        return "{" + strings.Join(keyVals, ", ") + "}"
 }
 
-// WithLabels returns a new context.Context with the given labels added.
+// 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.
@@ -72,7 +72,7 @@ func WithLabels(ctx context.Context, labels LabelSet) context.Context {
 }
 
 // Labels takes an even number of strings representing key-value pairs
-// and makes a LabelSet containing them.
+// and makes a [LabelSet] containing them.
 // A label overwrites a prior label with the same key.
 // Currently only the CPU and goroutine profiles utilize any labels
 // information.