1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-27 00:11:17 +02:00

Merge remote-tracking branch 'origin/master' into flakes

This commit is contained in:
Eelco Dolstra 2019-12-11 14:53:30 +01:00
commit ecb3a1afa2
119 changed files with 3905 additions and 2250 deletions

View file

@ -189,22 +189,22 @@ Path dirOf(const Path & path)
}
string baseNameOf(const Path & path)
std::string_view baseNameOf(std::string_view path)
{
if (path.empty())
return "";
Path::size_type last = path.length() - 1;
auto last = path.size() - 1;
if (path[last] == '/' && last > 0)
last -= 1;
Path::size_type pos = path.rfind('/', last);
auto pos = path.rfind('/', last);
if (pos == string::npos)
pos = 0;
else
pos += 1;
return string(path, pos, last - pos + 1);
return path.substr(pos, last - pos + 1);
}
@ -1307,9 +1307,10 @@ bool hasPrefix(const string & s, const string & prefix)
}
bool hasSuffix(const string & s, const string & suffix)
bool hasSuffix(std::string_view s, std::string_view suffix)
{
return s.size() >= suffix.size() && string(s, s.size() - suffix.size()) == suffix;
return s.size() >= suffix.size()
&& s.substr(s.size() - suffix.size()) == suffix;
}