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] Migrate constants to use string_view #26710

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Commits on Nov 24, 2024

  1. [CodeHealth] Migrate constants to use string_view

    This PR changes a few places where we used to have we had something
    like:
    
    ```cxx
    constexpr const char* kConstant[] = ...
    ```
    
    These arrays array are not as safe as proper containers. There's also
    the challange that the strings referred by these arrays cannot have
    their sizes encoded on the type, so there's a certain reliance on
    `strlen` to determine the size.
    
    This change converts on of these arrays to `std::array`. The other array
    was converted to a `constexpr` flat set, as that is what this array was
    being used for. This flat set requires a custom comparator though, as
    the search of the elements as matching against `end_with`. With this
    change, the lookup will be a bit less wasteful.
    
    Resolves brave/brave-browser#42484
    cdesouza-chromium committed Nov 24, 2024
    Configuration menu
    Copy the full SHA
    9623be9 View commit details
    Browse the repository at this point in the history