summaryrefslogtreecommitdiffstats
path: root/libcxx/include/algorithm
diff options
context:
space:
mode:
authorMarshall Clow <mclow.lists@gmail.com>2015-02-02 16:44:11 +0000
committerMarshall Clow <mclow.lists@gmail.com>2015-02-02 16:44:11 +0000
commit526e0929a5f8ba293fa200f7c5b78682136dcf84 (patch)
tree4dff22f0fe7aa55cb17cd3b4387f194eca975cdc /libcxx/include/algorithm
parent535ee9785328306b26904b01afcca0fa6b2df291 (diff)
downloadbcm5719-llvm-526e0929a5f8ba293fa200f7c5b78682136dcf84.tar.gz
bcm5719-llvm-526e0929a5f8ba293fa200f7c5b78682136dcf84.zip
Reorder a couple of operations in inplace_merge so that we can meet the complexity guidelines mandated by the standard. References PR22427
llvm-svn: 227808
Diffstat (limited to 'libcxx/include/algorithm')
-rw-r--r--libcxx/include/algorithm8
1 files changed, 3 insertions, 5 deletions
diff --git a/libcxx/include/algorithm b/libcxx/include/algorithm
index 02cbc816f61..a179acf63f2 100644
--- a/libcxx/include/algorithm
+++ b/libcxx/include/algorithm
@@ -4407,6 +4407,9 @@ __inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle,
// 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 __first, _BidirectionalIterator __middle,
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
OpenPOWER on IntegriCloud