Constify SyncJournalDb::findPathInSelectiveSyncList

Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
Claudio Cambra 2023-07-10 17:20:23 +08:00
parent 74c4ec88a2
commit 1b73011f59
No known key found for this signature in database
GPG Key ID: C839200C384636B0

View File

@ -207,24 +207,24 @@ bool SyncJournalDb::maybeMigrateDb(const QString &localPath, const QString &abso
bool SyncJournalDb::findPathInSelectiveSyncList(const QStringList &list, const QString &path)
{
Q_ASSERT(std::is_sorted(list.begin(), list.end()));
Q_ASSERT(std::is_sorted(list.cbegin(), list.cend()));
if (list.size() == 1 && list.first() == QLatin1String("/")) {
if (list.size() == 1 && list.first() == QStringLiteral("/")) {
// Special case for the case "/" is there, it matches everything
return true;
}
QString pathSlash = path + QLatin1Char('/');
const QString pathSlash = path + QLatin1Char('/');
// Since the list is sorted, we can do a binary search.
// If the path is a prefix of another item or right after in the lexical order.
auto it = std::lower_bound(list.begin(), list.end(), pathSlash);
auto it = std::lower_bound(list.cbegin(), list.cend(), pathSlash);
if (it != list.end() && *it == pathSlash) {
if (it != list.cend() && *it == pathSlash) {
return true;
}
if (it == list.begin()) {
if (it == list.cbegin()) {
return false;
}
--it;