Skip to content

Commit

Permalink
funcr: optimize WithValues/WithName/WithCallDepth
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
pohly authored and thockin committed Dec 3, 2022
1 parent 00ed9d0 commit 4d25940
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions funcr/funcr.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ func newFormatter(opts Options, outfmt outputFormat) Formatter {
prefix: "",
values: nil,
depth: 0,
opts: opts,
opts: &opts,
}
return f
}
Expand All @@ -232,7 +232,7 @@ type Formatter struct {
values []interface{}
valuesStr string
depth int
opts Options
opts *Options
}

// outputFormat indicates which outputFormat to use.
Expand Down

0 comments on commit 4d25940

Please sign in to comment.