mirror of
https://github.com/NixOS/nix
synced 2025-06-27 00:11:17 +02:00
isInDir() / isDirOrInDir(): Use std::string_view
This commit is contained in:
parent
be64fb9b51
commit
e1a0359b59
2 changed files with 10 additions and 8 deletions
|
@ -196,16 +196,16 @@ std::string_view baseNameOf(std::string_view path)
|
|||
}
|
||||
|
||||
|
||||
bool isInDir(const Path & path, const Path & dir)
|
||||
bool isInDir(std::string_view path, std::string_view dir)
|
||||
{
|
||||
return path[0] == '/'
|
||||
&& string(path, 0, dir.size()) == dir
|
||||
return path.substr(0, 1) == "/"
|
||||
&& path.substr(0, dir.size()) == dir
|
||||
&& path.size() >= dir.size() + 2
|
||||
&& path[dir.size()] == '/';
|
||||
}
|
||||
|
||||
|
||||
bool isDirOrInDir(const Path & path, const Path & dir)
|
||||
bool isDirOrInDir(std::string_view path, std::string_view dir)
|
||||
{
|
||||
return path == dir || isInDir(path, dir);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue