aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/profiles.cc
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2022-02-25 16:00:00 +0100
committerEelco Dolstra <edolstra@gmail.com>2022-02-25 16:13:02 +0100
commitdf552ff53e68dff8ca360adbdbea214ece1d08ee (patch)
tree9ed3cb700377d4731b4c234ebec16efb0099c71a /src/libstore/profiles.cc
parent14b38d0887f8a8d6b75039113eface57cfb19d06 (diff)
Remove std::string alias (for real this time)
Also use std::string_view in a few more places.
Diffstat (limited to 'src/libstore/profiles.cc')
-rw-r--r--src/libstore/profiles.cc16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/libstore/profiles.cc b/src/libstore/profiles.cc
index 73163424c..3e4188188 100644
--- a/src/libstore/profiles.cc
+++ b/src/libstore/profiles.cc
@@ -15,12 +15,12 @@ namespace nix {
/* Parse a generation name of the format
`<profilename>-<number>-link'. */
-static std::optional<GenerationNumber> parseName(const string & profileName, const string & name)
+static std::optional<GenerationNumber> parseName(const std::string & profileName, const std::string & name)
{
- if (string(name, 0, profileName.size() + 1) != profileName + "-") return {};
- string s = string(name, profileName.size() + 1);
- string::size_type p = s.find("-link");
- if (p == string::npos) return {};
+ if (name.substr(0, profileName.size() + 1) != profileName + "-") return {};
+ auto s = name.substr(profileName.size() + 1);
+ auto p = s.find("-link");
+ if (p == std::string::npos) return {};
if (auto n = string2Int<unsigned int>(s.substr(0, p)))
return *n;
else
@@ -209,13 +209,13 @@ void deleteGenerationsOlderThan(const Path & profile, time_t t, bool dryRun)
}
-void deleteGenerationsOlderThan(const Path & profile, const string & timeSpec, bool dryRun)
+void deleteGenerationsOlderThan(const Path & profile, std::string_view timeSpec, bool dryRun)
{
if (timeSpec.empty() || timeSpec[timeSpec.size() - 1] != 'd')
throw UsageError("invalid number of days specifier '%1%', expected something like '14d'", timeSpec);
time_t curTime = time(0);
- string strDays = string(timeSpec, 0, timeSpec.size() - 1);
+ auto strDays = timeSpec.substr(0, timeSpec.size() - 1);
auto days = string2Int<int>(strDays);
if (!days || *days < 1)
@@ -274,7 +274,7 @@ void lockProfile(PathLocks & lock, const Path & profile)
}
-string optimisticLockProfile(const Path & profile)
+std::string optimisticLockProfile(const Path & profile)
{
return pathExists(profile) ? readLink(profile) : "";
}