From f08ce98396d120421d06308b0680201210c71436 Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Fri, 22 Sep 2017 18:15:07 -0500 Subject: [PATCH] Fix strict weak ordering issue with std::sort comparator #261 --- libraries/chain/block_schedule.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/libraries/chain/block_schedule.cpp b/libraries/chain/block_schedule.cpp index 447eb69bc5a..cb047cf855b 100644 --- a/libraries/chain/block_schedule.cpp +++ b/libraries/chain/block_schedule.cpp @@ -57,13 +57,7 @@ struct schedule_entry { std::reference_wrapper 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); } }; @@ -72,7 +66,7 @@ static block_schedule from_entries(vector& 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);