Skip to content

Commit

Permalink
Reduce duplications of codes in parallel::partition.
Browse files Browse the repository at this point in the history
  • Loading branch information
taeguk committed Jul 27, 2017
1 parent f9cbe12 commit 514c5e3
Showing 1 changed file with 8 additions and 17 deletions.
25 changes: 8 additions & 17 deletions hpx/parallel/algorithms/partition.hpp
Expand Up @@ -616,27 +616,31 @@ namespace hpx { namespace parallel { inline namespace v1
{
using hpx::util::invoke;

while (invoke(pred, invoke(proj, *left_iter->first)))
while (true)
{
++left_iter->first;
if (left_iter->empty())
{
++left_iter;
if (left_iter == std::end(remaining_blocks) ||
left_iter->block_no > 0)
break;
}
if (!invoke(pred, invoke(proj, *left_iter->first)))
break;
++left_iter->first;
}

while (!invoke(pred, invoke(proj, *right_iter->first)))
while (true)
{
++right_iter->first;
if (right_iter->empty())
{
if (right_iter == std::begin(remaining_blocks) ||
(--right_iter)->block_no < 0)
break;
}
if (invoke(pred, invoke(proj, *right_iter->first)))
break;
++right_iter->first;
}

if (left_iter == std::end(remaining_blocks) ||
Expand All @@ -647,19 +651,6 @@ namespace hpx { namespace parallel { inline namespace v1
break;

std::iter_swap(left_iter->first++, right_iter->first++);
if (left_iter->empty())
{
++left_iter;
if (left_iter == std::end(remaining_blocks) ||
left_iter->block_no > 0)
break;
}
if (right_iter->empty())
{
if (right_iter == std::begin(remaining_blocks) ||
(--right_iter)->block_no < 0)
break;
}
}

if (left_iter < right_iter ||
Expand Down

0 comments on commit 514c5e3

Please sign in to comment.