-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
perf: fmt.Errorf
used instead of errors.New
#9749
Labels
priority: p2
Moderately-important priority. Fix may not be included in next release.
type: bug
Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Comments
codyoss
added
type: bug
Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
priority: p2
Moderately-important priority. Fix may not be included in next release.
labels
Apr 11, 2024
Thanks for the detailed report. This is a good suggestion. It looks like a good number of these are in our generated code so we can patch our generator to remove a lot of these and gofmt the rest. |
codyoss
added a commit
to codyoss/gapic-generator-go
that referenced
this issue
Apr 11, 2024
codyoss
added a commit
to googleapis/gapic-generator-go
that referenced
this issue
Apr 11, 2024
@codyoss Can this be closed now? |
There are still 137 cases of |
egonelbre
added a commit
to egonelbre/google-cloud-go
that referenced
this issue
Aug 22, 2024
Fixed automatically with: go fmt -w -r "fmt.Errorf(s) -> errors.New(s)" . goimports -w . Updates googleapis#9749
This was referenced Aug 22, 2024
gcf-merge-on-green bot
pushed a commit
that referenced
this issue
Sep 25, 2024
- perf(spanner): avoid using fmt.Errorf unnecessarily - perf(spanner): avoid duplicated errors.New in UnmarshalJSON - fix(spanner): error strings should not be capitalized Updates #9749
This was referenced Nov 18, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
priority: p2
Moderately-important priority. Fix may not be included in next release.
type: bug
Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Throughout the whole codebase there are many places that use
fmt.Errorf
whereaserrors.New
can be used. Usingfmt.Errorf
is roughly 4x slower thanerrors.New
.This can be easily benchmarked with:
On my computer I'm getting:
This performance issue can be automatically fixed with:
Those error paths usually aren't hot paths, however it might impact the size of code generated.
The text was updated successfully, but these errors were encountered: