canonical/mir
Vedi su GitHubReplace `str(n)?cmp` with `std::string_view::operator==`
Open
#4567 aperta il 16 dic 2025
Good first issue
Metriche repository
- Star
- (775 star)
- Metriche merge PR
- (Metriche PR in attesa)
Descrizione
Lots of places in ourcodebase read strings from the environment or some external source and compare them to other strings. The use of str(n)?cmp can sometimes be confusing, and while std::string_view{string1} == std::string_view{string2} is a bit more verbose, it's a lot easier to reason about at a glance than strcmp(string1,string2) != 0.
Additionally, strncmp can be usually replaced with std::string_view::starts_with.
Examples:
If std::string_view{...} == std::string_view{...} is too verbose, maybe wrapping that in a utility function would be a good middle ground?