From d37792b0cd112986236addbcde01ee55067c946b Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Wed, 6 May 2009 17:58:50 +0000 Subject: DeliveryRecord optimizations. Replace linear search with binary search. Collapse multi-pass mark-then-erase to a signle pass. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@772384 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/qpid/broker/TxAccept.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'cpp/src/qpid/broker/TxAccept.cpp') diff --git a/cpp/src/qpid/broker/TxAccept.cpp b/cpp/src/qpid/broker/TxAccept.cpp index ca128b1975..15a1222a74 100644 --- a/cpp/src/qpid/broker/TxAccept.cpp +++ b/cpp/src/qpid/broker/TxAccept.cpp @@ -58,15 +58,10 @@ void TxAccept::RangeOps::commit() std::for_each(ranges.begin(), ranges.end(), bind(&RangeOp::commit, _1)); //now remove if isRedundant(): if (!ranges.empty()) { - DeliveryRecords::iterator i = ranges.front().range.start; + DeliveryRecords::iterator begin = ranges.front().range.start; DeliveryRecords::iterator end = ranges.back().range.end; - while (i != end) { - if (i->isRedundant()) { - i = unacked.erase(i); - } else { - i++; - } - } + DeliveryRecords::iterator removed = remove_if(begin, end, mem_fun_ref(&DeliveryRecord::isRedundant)); + unacked.erase(removed, end); } } -- cgit v1.2.1