Skip to content

Commit 4d25940

Browse files
pohlythockin
authored andcommitted
funcr: optimize WithValues/WithName/WithCallDepth
All of these functions indirectly copied the entire Options struct because it gets stored by value in the Formatter and thus fnlogger. The struct is read-only, therefore sharing a single copy by pointer via different logger instances is possible. Performance for the context value benchmark got better.
1 parent 00ed9d0 commit 4d25940

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

funcr/funcr.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ func newFormatter(opts Options, outfmt outputFormat) Formatter {
218218
prefix: "",
219219
values: nil,
220220
depth: 0,
221-
opts: opts,
221+
opts: &opts,
222222
}
223223
return f
224224
}
@@ -232,7 +232,7 @@ type Formatter struct {
232232
values []interface{}
233233
valuesStr string
234234
depth int
235-
opts Options
235+
opts *Options
236236
}
237237

238238
// outputFormat indicates which outputFormat to use.

0 commit comments

Comments
 (0)