Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
Fix strict weak ordering issue with std::sort comparator #261
Browse files Browse the repository at this point in the history
  • Loading branch information
heifner committed Sep 22, 2017
1 parent 38c6554 commit f08ce98
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions libraries/chain/block_schedule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,7 @@ struct schedule_entry {
std::reference_wrapper<const pending_transaction> transaction;

friend bool operator<( const schedule_entry& l, const schedule_entry& r ) {
if (l.cycle < r.cycle) {
return true;
} else if (l.cycle == r.cycle) {
return l.thread < r.thread;
}

return false;
return std::tie(l.cycle, l.thread) < std::tie(r.cycle, r.thread);
}
};

Expand All @@ -72,7 +66,7 @@ static block_schedule from_entries(vector<schedule_entry>& entries) {
// for the highest cycle index first meaning the naive resize in the loop below
// is usually the largest and only resize
auto reverse = [](const schedule_entry& l, const schedule_entry& r) {
return !(l < r);
return std::tie(r.cycle, r.thread) < std::tie(l.cycle, l.thread);
};

std::sort(entries.begin(), entries.end(), reverse);
Expand Down

0 comments on commit f08ce98

Please sign in to comment.