From 9d8106dc957a433a4686b8e4ae3bed3f5aa06c41 Mon Sep 17 00:00:00 2001 From: leipeng Date: Sat, 25 Jun 2022 13:26:22 +0800 Subject: [PATCH] PointLockManager::UnLockKey: use swap instead of check --- utilities/transactions/lock/point/point_lock_manager.cc | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/utilities/transactions/lock/point/point_lock_manager.cc b/utilities/transactions/lock/point/point_lock_manager.cc index 8846cb87a..82897897b 100644 --- a/utilities/transactions/lock/point/point_lock_manager.cc +++ b/utilities/transactions/lock/point/point_lock_manager.cc @@ -587,10 +587,7 @@ void PointLockManager::UnLockKey(PessimisticTransaction* txn, if (txns.size() == 1) { stripe->keys.erase(stripe_iter); } else { - auto last_it = txns.end() - 1; - if (txn_it != last_it) { - *txn_it = *last_it; - } + std::swap(txns.back(), *txn_it); txns.pop_back(); }