Skip to content
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

[CodeHealth][wallet] Migrate more utils to string_view #26688

Merged
merged 1 commit into from
Nov 22, 2024

Conversation

cdesouza-chromium
Copy link
Collaborator

@cdesouza-chromium cdesouza-chromium commented Nov 22, 2024

Making string view more common will permit us to use more compile time constexpr globals in the application, as strings are passed around as compile time constants.

This is a follow up of #26683

Resolves brave/brave-browser#42445

Submitter Checklist:

  • I confirm that no security/privacy review is needed and no other type of reviews are needed, or that I have requested them
  • There is a ticket for my issue
  • Used Github auto-closing keywords in the PR description above
  • Wrote a good PR/commit description
  • Squashed any review feedback or "fixup" commits before merge, so that history is a record of what happened in the repo, not your PR
  • Added appropriate labels (QA/Yes or QA/No; release-notes/include or release-notes/exclude; OS/...) to the associated issue
  • Checked the PR locally:
    • npm run test -- brave_browser_tests, npm run test -- brave_unit_tests wiki
    • npm run presubmit wiki, npm run gn_check, npm run tslint
  • Ran git rebase master (if needed)

Reviewer Checklist:

  • A security review is not needed, or a link to one is included in the PR description
  • New files have MPL-2.0 license header
  • Adequate test coverage exists to prevent regressions
  • Major classes, functions and non-trivial code blocks are well-commented
  • Changes in component dependencies are properly reflected in gn
  • Code follows the style guide
  • Test plan is specified in PR before merging

After-merge Checklist:

Test Plan:

Copy link
Collaborator

@supermassive supermassive left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wallet core lgtm

@cdesouza-chromium cdesouza-chromium force-pushed the migrate-wallet-utils-to-string-view branch from 4bd17e8 to 73486bb Compare November 22, 2024 09:46
Making string view more common will permit us to use more compile time
`constexpr` globals in the application, as strings are passed around as
compile time constants.

Resolves brave/brave-browser#42445
@cdesouza-chromium cdesouza-chromium force-pushed the migrate-wallet-utils-to-string-view branch from 73486bb to df36889 Compare November 22, 2024 10:29
@wknapik wknapik merged commit 4762541 into master Nov 22, 2024
15 of 16 checks passed
@wknapik wknapik deleted the migrate-wallet-utils-to-string-view branch November 22, 2024 13:28
@github-actions github-actions bot added this to the 1.75.x - Nightly milestone Nov 22, 2024
@wknapik
Copy link
Collaborator

wknapik commented Nov 22, 2024

Force-merged due to a failed CI status update on iOS, which passed

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 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
@brave-builds
Copy link
Collaborator

Released in v1.75.45

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Migrate chrome wallet utils to use string_view to make it constexpr friendly
4 participants