diff options
author | Jade Lovelace <lix@jade.fyi> | 2024-03-17 19:14:18 -0700 |
---|---|---|
committer | Jade Lovelace <lix@jade.fyi> | 2024-03-17 20:17:19 -0700 |
commit | 61e21b25576f7f3491f6a837bf59d8b44c6897a0 (patch) | |
tree | 3f62d83b3bab84afcf1011b5c2353226b84313b3 /src/libutil/cgroup.cc | |
parent | 706cee5c493b39e25bdb0add55d2e1771dc31696 (diff) |
Delete hasPrefix and hasSuffix from the codebase
These now have equivalents in the standard lib in C++20. This change was
performed with a custom clang-tidy check which I will submit later.
Executed like so:
ninja -C build && run-clang-tidy -checks='-*,nix-*' -load=build/libnix-clang-tidy.so -p .. -fix ../tests | tee -a clang-tidy-result
Change-Id: I62679e315ff9e7ce72a40b91b79c3e9fc01b27e9
Diffstat (limited to 'src/libutil/cgroup.cc')
-rw-r--r-- | src/libutil/cgroup.cc | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/libutil/cgroup.cc b/src/libutil/cgroup.cc index a008481ca..9320d2371 100644 --- a/src/libutil/cgroup.cc +++ b/src/libutil/cgroup.cc @@ -41,7 +41,7 @@ std::map<std::string, std::string> getCgroups(const Path & cgroupFile) if (!std::regex_match(line, match, regex)) throw Error("invalid line '%s' in '%s'", line, cgroupFile); - std::string name = hasPrefix(std::string(match[2]), "name=") ? std::string(match[2], 5) : match[2]; + std::string name = std::string(match[2]).starts_with("name=") ? std::string(match[2], 5) : match[2]; cgroups.insert_or_assign(name, match[3]); } @@ -117,13 +117,13 @@ static CgroupStats destroyCgroup(const Path & cgroup, bool returnStats) if (pathExists(cpustatPath)) { for (auto & line : tokenizeString<std::vector<std::string>>(readFile(cpustatPath), "\n")) { std::string_view userPrefix = "user_usec "; - if (hasPrefix(line, userPrefix)) { + if (line.starts_with(userPrefix)) { auto n = string2Int<uint64_t>(line.substr(userPrefix.size())); if (n) stats.cpuUser = std::chrono::microseconds(*n); } std::string_view systemPrefix = "system_usec "; - if (hasPrefix(line, systemPrefix)) { + if (line.starts_with(systemPrefix)) { auto n = string2Int<uint64_t>(line.substr(systemPrefix.size())); if (n) stats.cpuSystem = std::chrono::microseconds(*n); } |