-
Notifications
You must be signed in to change notification settings - Fork 883
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
[CodeHealht][wallet] Avoid NoDestructor
in eth_data_builder.cc
#26683
Merged
Conversation
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
The use of `NoDestructor` for a map of strings in `ChainIdToVersion` is wasteful of resources, when the actual data can be seen at compile time. This PR converts this static `std::map` into a fixed flat map. This required changing the type of the elements to `string_view`, so this PR goes a bit the extra mile to modernise some of the functions around to use `string_view`. Resolve brave/brave-browser#42432
SergeyZhukovsky
approved these changes
Nov 21, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
++
Thanks mate.. you are always ready in reviewing things. |
Released in v1.75.43 |
24 tasks
cdesouza-chromium
added a commit
that referenced
this pull request
Nov 22, 2024
This function has been returning a vector of strings, to be used by `GetMany`, and therefore a `NoDestructor` instance is needed. However, the only reason why this has to be a vector of strings is because in the end `EncodeStringArray` requires a vector of strings. This PR changes `EncodeStringArray` to take spans of strings and of string views. This will allows to convert the keys into a `constexpr` value, and avoid the use of `NoDestructor`. In a follow up PR, additional callsites of `EncodeStringArray` may be migrated to the `string_view` variant. This is a follow up of these PRs: #26683 #26688 Resolves brave/brave-browser#42453
24 tasks
cdesouza-chromium
added a commit
that referenced
this pull request
Nov 22, 2024
This function has been returning a vector of strings, to be used by `GetMany`, and therefore a `NoDestructor` instance is needed. However, the only reason why this has to be a vector of strings is because in the end `EncodeStringArray` requires a vector of strings. This PR changes `EncodeStringArray` to take spans of strings and of string views. This will allows to convert the keys into a `constexpr` value, and avoid the use of `NoDestructor`. In a follow up PR, additional callsites of `EncodeStringArray` may be migrated to the `string_view` variant. This is a follow up of these PRs: #26683 #26688 Resolves brave/brave-browser#42453
cdesouza-chromium
added a commit
that referenced
this pull request
Nov 23, 2024
This function has been returning a vector of strings, to be used by `GetMany`, and therefore a `NoDestructor` instance is needed. However, the only reason why this has to be a vector of strings is because in the end `EncodeStringArray` requires a vector of strings. This PR changes `EncodeStringArray` to take spans of strings and of string views. This will allows to convert the keys into a `constexpr` value, and avoid the use of `NoDestructor`. In a follow up PR, additional callsites of `EncodeStringArray` may be migrated to the `string_view` variant. This is a follow up of these PRs: #26683 #26688 Resolves brave/brave-browser#42453
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 use of
NoDestructor
for a map of strings inChainIdToVersion
is wasteful of resources, when the actual data can be seen at compile time.This PR converts this static
std::map
into a fixed flat map. This required changing the type of the elements tostring_view
, so this PR goes a bit the extra mile to modernise some of the functions around to usestring_view
.Resolve brave/brave-browser#42432
Resolves
Submitter Checklist:
QA/Yes
orQA/No
;release-notes/include
orrelease-notes/exclude
;OS/...
) to the associated issuenpm run test -- brave_browser_tests
,npm run test -- brave_unit_tests
wikinpm run presubmit
wiki,npm run gn_check
,npm run tslint
git rebase master
(if needed)Reviewer Checklist:
gn
After-merge Checklist:
changes has landed on
Test Plan: