Skip to content

Commit

Permalink
rocket/fwd: Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
lhmouse committed Sep 2, 2024
1 parent 5a3fc2c commit 4ca2a36
Showing 1 changed file with 16 additions and 20 deletions.
36 changes: 16 additions & 20 deletions rocket/fwd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ rotate(elementT* ptr, size_t begin, size_t seek, size_t end)
if(isr == 0)
return;

for(;;)
while(isl != isr)
if(isl < isr) {
// Before:
// stp end
Expand All @@ -569,12 +569,12 @@ rotate(elementT* ptr, size_t begin, size_t seek, size_t end)
swap(ptr[bot++], ptr[brk++]);
while(bot != stp);

// `isr` will have been decreased by `isl`, which will
// `isr` has been decreased by `isl`, which will
// not yield zero. `isl` is unchanged.
stp = brk;
isr = end - brk;
}
else if(isl > isr) {
else {
// Before:
// stp end
// bot brk
Expand All @@ -588,28 +588,24 @@ rotate(elementT* ptr, size_t begin, size_t seek, size_t end)
swap(ptr[bot++], ptr[brk++]);
while(brk != end);

// `isl` will have been decreased by `isr`, which will
// `isl` has been decreased by `isr`, which will
// not yield zero. `isr` is unchanged.
brk = stp;
isl = stp - bot;
}
else {
// Before:
// stp end
// bot brk
// > 0 1 2 3 4 5 6 7 8 9 -
//
// After:
// stp end
// bot brk
// > 5 6 7 8 9 0 1 2 3 4 -
do
swap(ptr[bot++], ptr[brk++]);
while(bot != stp);

// `brk` equals `end` so there is no more work to do.
break;
}
// Before:
// stp end
// bot brk
// > 0 1 2 3 4 5 6 7 8 9 -
//
// After:
// stp end
// bot brk
// > 5 6 7 8 9 0 1 2 3 4 -
do
swap(ptr[bot++], ptr[brk++]);
while(bot != stp);
}

template<typename containerT, typename callbackT>
Expand Down

0 comments on commit 4ca2a36

Please sign in to comment.