Skip to content

Conversation

@jvoisin
Copy link
Collaborator

@jvoisin jvoisin commented Oct 4, 2025

No need to to invoke the whole Printf machinery for constant strings. While this shouldn't have an impact on memory consumption nor allocation (as constructing errors to return is never in a hot path), this should reduce a bit the code size, as errors.New will be inlined to a simple struct initialization instead of a function call.

@fguillot
Copy link
Member

fguillot commented Oct 4, 2025

Let's fix all of them while you are at it. After that, we can have a linter check.

go install github.com/catenacyber/perfsprint@latest
perfsprint ./...

Remaining things to fix which can be fixed automatically with perfsprint -fix ./...

/home/fred/repos/miniflux/v2/internal/integration/linkwarden/linkwarden.go:30:10: error-format: fmt.Errorf can be replaced with errors.New
/home/fred/repos/miniflux/v2/internal/integration/linkwarden/linkwarden.go:9:2: fiximports: Fix imports
/home/fred/repos/miniflux/v2/internal/googlereader/handler.go:282:9: error-format: fmt.Errorf can be replaced with errors.New
/home/fred/repos/miniflux/v2/internal/googlereader/handler.go:1016:39: integer-format: fmt.Sprint can be replaced with faster strconv.FormatInt
/home/fred/repos/miniflux/v2/internal/googlereader/handler.go:1016:100: integer-format: fmt.Sprint can be replaced with faster strconv.FormatInt
/home/fred/repos/miniflux/v2/internal/googlereader/handler.go:1050:26: error-format: fmt.Errorf can be replaced with errors.New
/home/fred/repos/miniflux/v2/internal/googlereader/item.go:61:15: error-format: fmt.Errorf can be replaced with errors.New
/home/fred/repos/miniflux/v2/internal/googlereader/request_modifier.go:52:28: string-format: fmt.Sprintf can be replaced with string concatenation
/home/fred/repos/miniflux/v2/internal/googlereader/request_modifier.go:53:28: string-format: fmt.Sprintf can be replaced with string concatenation
/home/fred/repos/miniflux/v2/internal/googlereader/item.go:7:2: fiximports: Fix imports
/home/fred/repos/miniflux/v2/client/client.go:128:29: string-format: fmt.Sprintf can be replaced with string concatenation

No need to to invoke the whole Printf machinery for constant strings. While
this shouldn't have an impact on memory consumption nor allocation (as
constructing errors to return is never in a hot path), this should reduce a bit
the code size, as errors.New will be inlined to a simple struct initialization
instead of a function call.
@jvoisin
Copy link
Collaborator Author

jvoisin commented Oct 6, 2025

I was in the process of writing a linter :P

@fguillot fguillot merged commit dd44fbc into miniflux:main Oct 7, 2025
9 checks passed
dsh2dsh added a commit to dsh2dsh/miniflux that referenced this pull request Oct 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants