canonical/mir
GitHub で見るReplace `str(n)?cmp` with `std::string_view::operator==`
Open
#4,567 opened on 2025年12月16日
Good first issue
Repository metrics
- Stars
- (775 stars)
- PR merge metrics
- (PR metrics pending)
説明
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?