-
Notifications
You must be signed in to change notification settings - Fork 119
Open
Labels
Good first issueGood for newcomersGood for newcomers
Description
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:
mir/examples/miral-shell/shell_main.cpp
Lines 59 to 61 in 7a9370b
| if (strcmp(strategy, "always-ssd") == 0) return miral::Decorations::always_ssd(); | |
| if (strcmp(strategy, "prefer-ssd") == 0) return miral::Decorations::prefer_ssd(); | |
| if (strcmp(strategy, "always-csd") == 0) return miral::Decorations::always_csd(); |
| if (strcmp(wl_resource_get_class(surface), "wl_surface") != 0) |
If std::string_view{...} == std::string_view{...} is too verbose, maybe wrapping that in a utility function would be a good middle ground?
Metadata
Metadata
Assignees
Labels
Good first issueGood for newcomersGood for newcomers