Repository navigation
chore(state): v1LegacyLayout keys no longer use fmt.Sprintf(). - #4484
Merged
Merged
Conversation
alesforz
marked this pull request as ready for review
November 13, 2024 14:33
Collaborator
|
Maybe you can do the same for the blockStore? https://github.com/cometbft/cometbft/blob/alesforz/v1keylayout-sprintf/store/db_key_layout.go |
Collaborator
Author
Will do it in a separate PR 👍 |
Collaborator
Author
|
Note: the changes in this PR are superseded by #4490. |
mergify Bot
added a commit
that referenced
this pull request
Nov 20, 2024
This PR refactors the `v1LegacyLayout` key creation to improve its speed and reduce its memory usage. Follow up to #4484. --- #### PR checklist - [x] Tests written/updated - [x] Changelog entry added in `.changelog` (we use [unclog](https://github.com/informalsystems/unclog) to manage our changelog) - [x] Updated relevant documentation (`docs/` or `spec/`) and code comments --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
v1LegacyLayouttype usesfmt.Sprintf()to create the DB keys. This PR substitutesfmt.Sprintfwith string concatenation, which is 3-4 times faster for such a simple string.In general, we shouldn't use
fmt.Sprintf()to concatenate strings, because it's inefficient.Exceptions could be constructing error messages (but we should use
fmt.Errorf()for that) or tests.PR checklist
[ ] Tests written/updated.changelog(we use unclog to manage our changelog)[ ] Updated relevant documentation (docs/orspec/) and code comments