Skip to content

Commit d672a1d

Browse files
committed
Use string::starts_with
1 parent e32986e commit d672a1d

File tree

4 files changed

+5
-7
lines changed

4 files changed

+5
-7
lines changed

src/list_issues.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ auto read_file_into_string(fs::path const & filename) -> std::string {
6161
auto is_issue_xml_file(fs::directory_entry const & e) {
6262
if (e.is_regular_file()) {
6363
fs::path f = e.path().filename();
64-
return f.string().compare(0, 5, "issue") == 0 && f.extension() == ".xml";
64+
return f.string().starts_with("issue") && f.extension() == ".xml";
6565
}
6666
return false;
6767
}

src/lists.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ auto read_file_into_string(fs::path const & filename) -> std::string {
7373
auto is_issue_xml_file(fs::directory_entry const & e) {
7474
if (e.is_regular_file()) {
7575
fs::path f = e.path().filename();
76-
return f.string().compare(0, 5, "issue") == 0 && f.extension() == ".xml";
76+
return f.string().starts_with("issue") && f.extension() == ".xml";
7777
}
7878
return false;
7979
}

src/sections.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ auto lwg::format_section_tag_as_link(section_map & section_db, section_tag const
180180
std::string url;
181181
if (!tag.prefix.empty()) {
182182
std::string_view fund_ts = "fund.ts";
183-
if (tag.prefix.compare(0, fund_ts.size(), fund_ts) == 0) {
183+
if (tag.prefix.starts_with(fund_ts)) {
184184
std::string_view version = tag.prefix;
185185
version.remove_prefix(fund_ts.size());
186186
if (version.empty())

src/status.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,7 @@ auto lwg::is_closed(std::string_view stat) -> bool {
7373
}
7474

7575
auto lwg::is_tentative(std::string_view stat) -> bool {
76-
// a more efficient implementation will use some variation of strcmp
77-
std::string_view tent{"Tentatively"};
78-
return 0 == stat.compare(0, tent.size(), tent);
76+
return stat.starts_with("Tentatively");
7977
}
8078

8179
auto lwg::is_assigned_to_another_group(std::string_view stat) -> bool {
@@ -104,7 +102,7 @@ auto lwg::is_ready(std::string_view stat) -> bool {
104102
// Functions to "normalize" a status string
105103
namespace {
106104
auto remove_prefix(std::string_view str, std::string_view prefix) -> std::string_view {
107-
if (0 == str.compare(0, prefix.size(), prefix)) {
105+
if (str.starts_with(prefix)) {
108106
str.remove_prefix(prefix.size() + 1);
109107
}
110108
return str;

0 commit comments

Comments
 (0)