diff options
author | John Ericson <John.Ericson@Obsidian.Systems> | 2022-03-10 16:20:01 +0000 |
---|---|---|
committer | John Ericson <John.Ericson@Obsidian.Systems> | 2022-03-10 16:20:01 +0000 |
commit | 938650700fafe76e3755982d670855fed3db35c6 (patch) | |
tree | 7a6ac217f87cad07bb963ec658bd60625b868466 /src/libstore/profiles.cc | |
parent | 195daa82995b43b3cbd552735a678afb85f4ae28 (diff) | |
parent | 8ba089597fa19bfd49ba5f22a5e821740ca4eb5d (diff) |
Merge branch 'path-info' into ca-drv-exotic
Diffstat (limited to 'src/libstore/profiles.cc')
-rw-r--r-- | src/libstore/profiles.cc | 16 |
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) : ""; } |