aboutsummaryrefslogtreecommitdiff
path: root/src/libcmd/installables.cc
diff options
context:
space:
mode:
authorJade Lovelace <lix@jade.fyi>2024-03-17 19:14:18 -0700
committerJade Lovelace <lix@jade.fyi>2024-03-17 20:17:19 -0700
commit61e21b25576f7f3491f6a837bf59d8b44c6897a0 (patch)
tree3f62d83b3bab84afcf1011b5c2353226b84313b3 /src/libcmd/installables.cc
parent706cee5c493b39e25bdb0add55d2e1771dc31696 (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/libcmd/installables.cc')
-rw-r--r--src/libcmd/installables.cc12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/libcmd/installables.cc b/src/libcmd/installables.cc
index f40136411..973db62b0 100644
--- a/src/libcmd/installables.cc
+++ b/src/libcmd/installables.cc
@@ -159,7 +159,7 @@ void MixFlakeOptions::completeFlakeInput(std::string_view prefix)
auto flakeRef = parseFlakeRefWithFragment(expandTilde(flakeRefS), absPath(".")).first;
auto flake = flake::getFlake(*evalState, flakeRef, true);
for (auto & input : flake.inputs)
- if (hasPrefix(input.first, prefix))
+ if (input.first.starts_with(prefix))
completions->add(input.first);
}
}
@@ -320,7 +320,7 @@ void completeFlakeRefWithFragment(
auto attrPath = parseAttrPath(*evalState, attrPathS);
std::string lastAttr;
- if (!attrPath.empty() && !hasSuffix(attrPathS, ".")) {
+ if (!attrPath.empty() && !attrPathS.ends_with(".")) {
lastAttr = evalState->symbols[attrPath.back()];
attrPath.pop_back();
}
@@ -329,7 +329,7 @@ void completeFlakeRefWithFragment(
if (!attr) continue;
for (auto & attr2 : (*attr)->getAttrs()) {
- if (hasPrefix(evalState->symbols[attr2], lastAttr)) {
+ if (std::string_view(evalState->symbols[attr2]).starts_with(lastAttr)) {
auto attrPath2 = (*attr)->getAttrPath(attr2);
/* Strip the attrpath prefix. */
attrPath2.erase(attrPath2.begin(), attrPath2.begin() + attrPathPrefix.size());
@@ -367,12 +367,12 @@ void completeFlakeRef(ref<Store> store, std::string_view prefix)
for (auto & registry : fetchers::getRegistries(store)) {
for (auto & entry : registry->entries) {
auto from = entry.from.to_string();
- if (!hasPrefix(prefix, "flake:") && hasPrefix(from, "flake:")) {
+ if (!prefix.starts_with("flake:") && from.starts_with("flake:")) {
std::string from2(from, 6);
- if (hasPrefix(from2, prefix))
+ if (from2.starts_with(prefix))
completions->add(from2);
} else {
- if (hasPrefix(from, prefix))
+ if (from.starts_with(prefix))
completions->add(from);
}
}