tuple: Make operator<() linear instead of exponential
Patch by Matthew Dempsky! git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@226641 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
b3289a0c88
commit
07b133f2a7
@ -927,8 +927,12 @@ struct __tuple_less
|
|||||||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
|
||||||
bool operator()(const _Tp& __x, const _Up& __y)
|
bool operator()(const _Tp& __x, const _Up& __y)
|
||||||
{
|
{
|
||||||
return __tuple_less<_Ip-1>()(__x, __y) ||
|
const size_t __idx = tuple_size<_Tp>::value - _Ip;
|
||||||
(!__tuple_less<_Ip-1>()(__y, __x) && _VSTD::get<_Ip-1>(__x) < _VSTD::get<_Ip-1>(__y));
|
if (_VSTD::get<__idx>(__x) < _VSTD::get<__idx>(__y))
|
||||||
|
return true;
|
||||||
|
if (_VSTD::get<__idx>(__y) < _VSTD::get<__idx>(__x))
|
||||||
|
return false;
|
||||||
|
return __tuple_less<_Ip-1>()(__x, __y);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user