1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-03-27 03:40:24 +00:00

Remove redundant startsWith function

This commit is contained in:
elsid 2023-12-17 15:22:00 +01:00
parent 225946b92b
commit 3363616f56
No known key found for this signature in database
GPG key ID: 4DE04C198CBA7625

View file

@ -70,21 +70,13 @@ namespace VFS
return found->second->getPath(); return found->second->getPath();
} }
namespace
{
bool startsWith(std::string_view text, std::string_view start)
{
return text.rfind(start, 0) == 0;
}
}
Manager::RecursiveDirectoryRange Manager::getRecursiveDirectoryIterator(std::string_view path) const Manager::RecursiveDirectoryRange Manager::getRecursiveDirectoryIterator(std::string_view path) const
{ {
if (path.empty()) if (path.empty())
return { mIndex.begin(), mIndex.end() }; return { mIndex.begin(), mIndex.end() };
std::string normalized = Path::normalizeFilename(path); std::string normalized = Path::normalizeFilename(path);
const auto it = mIndex.lower_bound(normalized); const auto it = mIndex.lower_bound(normalized);
if (it == mIndex.end() || !startsWith(it->first, normalized)) if (it == mIndex.end() || !it->first.starts_with(normalized))
return { it, it }; return { it, it };
++normalized.back(); ++normalized.back();
return { it, mIndex.lower_bound(normalized) }; return { it, mIndex.lower_bound(normalized) };