Skip to content

Commit 1aa0661

Browse files
committed
Cleanup checkpoint_manager.cc
* Simplify ternaries to inequality check * Use cursors.find() result instead of cursors.at() Change-Id: Ia370bb2cfcf9def8f06d42327a4fe08968a7d7fd Reviewed-on: https://review.couchbase.org/c/kv_engine/+/203523 Reviewed-by: Paolo Cocchi <[email protected]> Tested-by: Build Bot <[email protected]>
1 parent 00779bc commit 1aa0661

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

engines/ep/src/checkpoint_manager.cc

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -393,9 +393,7 @@ CursorRegResult CheckpointManager::registerCursorBySeqno(
393393
// nextSeqnoAvailableFromCheckpoint
394394
const uint64_t nextSeqnoAvailableFromCheckpoint = lastBySeqno + 1;
395395
const auto tryBackfill =
396-
(nextSeqnoAvailableFromCheckpoint == lastProcessedSeqno + 1
397-
? false
398-
: true);
396+
(nextSeqnoAvailableFromCheckpoint != lastProcessedSeqno + 1);
399397
return createCursorRegResult((*ckptIt)->begin(),
400398
0,
401399
tryBackfill,
@@ -465,8 +463,7 @@ CursorRegResult CheckpointManager::registerCursorBySeqno(
465463
if (lastProcessedSeqno < *st) {
466464
// Trigger backfill only if there's a gap between lastProcessedSeqno
467465
// and st
468-
const auto tryBackfill =
469-
(*st == lastProcessedSeqno + 1 ? false : true);
466+
const auto tryBackfill = (*st != lastProcessedSeqno + 1);
470467
return createCursorRegResult(ckpt.begin(), 0, tryBackfill, *st);
471468
}
472469

@@ -834,10 +831,9 @@ std::vector<Cursor> CheckpointManager::getListOfCursorsToDrop() {
834831
// the backup cursor exists. So that can be exploited to simplify
835832
// the logic further here.
836833

837-
const auto backupExists =
838-
cursors.find(backupPCursorName) != cursors.end();
839-
const auto& specialCursor = backupExists
840-
? *cursors.at(backupPCursorName)
834+
const auto backupFound = cursors.find(backupPCursorName);
835+
const auto& specialCursor = (backupFound != cursors.end())
836+
? *backupFound->second
841837
: *persistenceCursor;
842838

843839
for (const auto& pair : cursors) {
@@ -1294,8 +1290,8 @@ uint64_t CheckpointManager::getMaxVisibleSeqno() const {
12941290
std::shared_ptr<CheckpointCursor>
12951291
CheckpointManager::getBackupPersistenceCursor() {
12961292
std::lock_guard<std::mutex> lh(queueLock);
1297-
const auto exists = cursors.find(backupPCursorName) != cursors.end();
1298-
return exists ? cursors[backupPCursorName] : nullptr;
1293+
const auto backupFound = cursors.find(backupPCursorName);
1294+
return (backupFound != cursors.end()) ? backupFound->second : nullptr;
12991295
}
13001296

13011297
void CheckpointManager::dump() const {

0 commit comments

Comments
 (0)