Skip to content

Commit 1e3df74

Browse files
committed
refactor(syncengine): use std::ranges algorithms where applicable
Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
1 parent 6d51cc1 commit 1e3df74

1 file changed

Lines changed: 5 additions & 9 deletions

File tree

src/libsync/syncengine.cpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -479,8 +479,8 @@ void OCC::SyncEngine::slotItemDiscovered(const OCC::SyncFileItemPtr &item)
479479
_needsUpdate = true;
480480

481481
// Insert sorted
482-
auto it = std::lower_bound( _syncItems.begin(), _syncItems.end(), item ); // the _syncItems is sorted
483-
_syncItems.insert( it, item );
482+
const auto it = std::ranges::lower_bound(_syncItems, item); // the _syncItems is sorted
483+
_syncItems.insert(it, item);
484484

485485
slotNewItem(item);
486486

@@ -1157,13 +1157,9 @@ bool SyncEngine::shouldRestartSync() const
11571157
return false;
11581158
}
11591159

1160-
for (const auto &syncItem : _syncItems) {
1161-
// If there's at least one remove instruction to be propagated to the remote: bail out, we might have lost a local rename.
1162-
if (syncItem->_instruction == CSYNC_INSTRUCTION_REMOVE && syncItem->_direction == SyncFileItem::Up) {
1163-
return true;
1164-
}
1165-
}
1166-
return false;
1160+
return std::ranges::any_of(_syncItems, [](const auto &syncItem) {
1161+
return syncItem->_instruction == CSYNC_INSTRUCTION_REMOVE && syncItem->_direction == SyncFileItem::Up;
1162+
});
11671163
}
11681164

11691165
int SyncEngine::countDeletedFiles() const

0 commit comments

Comments
 (0)