[libcxx] r227808 - Reorder a couple of operations in inplace_merge so that we can meet the complexity guidelines mandated by the standard. References PR22427
Marshall Clow
mclow.lists at gmail.com
Mon Feb 2 08:44:11 PST 2015
Author: marshall
Date: Mon Feb 2 10:44:11 2015
New Revision: 227808
URL: http://llvm.org/viewvc/llvm-project?rev=227808&view=rev
Log:
Reorder a couple of operations in inplace_merge so that we can meet the complexity guidelines mandated by the standard. References PR22427
Modified:
libcxx/trunk/include/algorithm
Modified: libcxx/trunk/include/algorithm
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/algorithm?rev=227808&r1=227807&r2=227808&view=diff
==============================================================================
--- libcxx/trunk/include/algorithm (original)
+++ libcxx/trunk/include/algorithm Mon Feb 2 10:44:11 2015
@@ -4407,6 +4407,9 @@ __inplace_merge(_BidirectionalIterator _
// if __middle == __last, we're done
if (__len2 == 0)
return;
+ if (__len1 <= __buff_size || __len2 <= __buff_size)
+ return __buffered_inplace_merge<_Compare>
+ (__first, __middle, __last, __comp, __len1, __len2, __buff);
// shrink [__first, __middle) as much as possible (with no moves), returning if it shrinks to 0
for (; true; ++__first, (void) --__len1)
{
@@ -4415,11 +4418,6 @@ __inplace_merge(_BidirectionalIterator _
if (__comp(*__middle, *__first))
break;
}
- if (__len1 <= __buff_size || __len2 <= __buff_size)
- {
- __buffered_inplace_merge<_Compare>(__first, __middle, __last, __comp, __len1, __len2, __buff);
- return;
- }
// __first < __middle < __last
// *__first > *__middle
// partition [__first, __m1) [__m1, __middle) [__middle, __m2) [__m2, __last) such that
More information about the cfe-commits
mailing list