forked from uber-go/zap
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optimize Sugar logger for calls with a single string arg (uber-go#913)
Currently, the Sugar logger uses fmt.Sprint in all cases when the template is empty. However, this call is unnecessary if there's a single string type argument, as we can use it directly. With this optimization, we reduce the cost and avoid an unnecessary alloc: ``` > benchcmp pre post benchmark old ns/op new ns/op delta BenchmarkSugarSingleStrArg-10 636 570 -10.38% benchmark old allocs new allocs delta BenchmarkSugarSingleStrArg-10 1 0 -100.00% ```
- Loading branch information
Showing
2 changed files
with
27 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters