forked from OSchip/llvm-project
[libc++] Optimize the number of assignments in std::exclusive_scan
Reported in https://twitter.com/blelbach/status/1169807347142676480 Differential Revision: https://reviews.llvm.org/D67273
This commit is contained in:
parent
e0bf234930
commit
c30d5101f1
|
@ -335,14 +335,17 @@ exclusive_scan(_InputIterator __first, _InputIterator __last,
|
|||
{
|
||||
if (__first != __last)
|
||||
{
|
||||
_Tp __saved = __init;
|
||||
do
|
||||
_Tp __tmp(__b(__init, *__first));
|
||||
while (true)
|
||||
{
|
||||
__init = __b(__init, *__first);
|
||||
*__result = __saved;
|
||||
__saved = __init;
|
||||
*__result = _VSTD::move(__init);
|
||||
++__result;
|
||||
} while (++__first != __last);
|
||||
++__first;
|
||||
if (__first == __last)
|
||||
break;
|
||||
__init = _VSTD::move(__tmp);
|
||||
__tmp = __b(__init, *__first);
|
||||
}
|
||||
}
|
||||
return __result;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue