@@ -155,6 +155,13 @@ class edge_sort_iterator {
155
155
using pointer = edge_swapper*;
156
156
using difference_type = ssize_t ;
157
157
158
+ // In order for this class to be used as an iterator within the std library,
159
+ // it needs to "act" like a pointer. One thing that it should do is that a
160
+ // const variable of this type should be de-referenceable. Therefore, this
161
+ // method should be const method; however, this requires modifying the class
162
+ // and may yield worst performance. For now the std::stable_sort allows this
163
+ // but in the future it may not. If this breaks, this is why.
164
+ // See issue #2517 and PR #2522
158
165
edge_swapper& operator *() {
159
166
return this ->swapper_ ;
160
167
}
@@ -419,7 +426,7 @@ size_t t_rr_graph_storage::count_rr_switches(
419
426
// values.
420
427
//
421
428
// This sort is safe to do because partition_edges() has not been invoked yet.
422
- std::sort (
429
+ std::stable_sort (
423
430
edge_sort_iterator (this , 0 ),
424
431
edge_sort_iterator (this , edge_dest_node_.size ()),
425
432
edge_compare_dest_node ());
@@ -527,7 +534,7 @@ void t_rr_graph_storage::partition_edges(const vtr::vector<RRSwitchId, t_rr_swit
527
534
// by assign_first_edges()
528
535
// - Edges within a source node have the configurable edges before the
529
536
// non-configurable edges.
530
- std::sort (
537
+ std::stable_sort (
531
538
edge_sort_iterator (this , 0 ),
532
539
edge_sort_iterator (this , edge_src_node_.size ()),
533
540
edge_compare_src_node_and_configurable_first (rr_switches));
0 commit comments