@@ -155,6 +155,13 @@ class edge_sort_iterator {
155155 using pointer = edge_swapper*;
156156 using difference_type = ssize_t ;
157157
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
158165 edge_swapper& operator *() {
159166 return this ->swapper_ ;
160167 }
@@ -419,7 +426,7 @@ size_t t_rr_graph_storage::count_rr_switches(
419426 // values.
420427 //
421428 // This sort is safe to do because partition_edges() has not been invoked yet.
422- std::sort (
429+ std::stable_sort (
423430 edge_sort_iterator (this , 0 ),
424431 edge_sort_iterator (this , edge_dest_node_.size ()),
425432 edge_compare_dest_node ());
@@ -527,7 +534,7 @@ void t_rr_graph_storage::partition_edges(const vtr::vector<RRSwitchId, t_rr_swit
527534 // by assign_first_edges()
528535 // - Edges within a source node have the configurable edges before the
529536 // non-configurable edges.
530- std::sort (
537+ std::stable_sort (
531538 edge_sort_iterator (this , 0 ),
532539 edge_sort_iterator (this , edge_src_node_.size ()),
533540 edge_compare_src_node_and_configurable_first (rr_switches));
0 commit comments