33use intern:: Symbol ;
44use rustc_hash:: FxHashMap ;
55use span:: { Edition , Span } ;
6+ use stdx:: itertools:: Itertools ;
67use syntax:: {
78 ast:: { self , HasName } ,
89 AstNode ,
@@ -27,9 +28,10 @@ fn benchmark_parse_macro_rules() {
2728 let hash: usize = {
2829 let _pt = bench ( "mbe parse macro rules" ) ;
2930 rules
30- . values ( )
31- . map ( |it| {
32- DeclarativeMacro :: parse_macro_rules ( it, |_| span:: Edition :: CURRENT ) . rules . len ( )
31+ . into_iter ( )
32+ . sorted_by_key ( |( id, _) | id. clone ( ) )
33+ . map ( |( _, it) | {
34+ DeclarativeMacro :: parse_macro_rules ( & it, |_| span:: Edition :: CURRENT ) . rules . len ( )
3335 } )
3436 . sum ( )
3537 } ;
@@ -55,12 +57,13 @@ fn benchmark_expand_macro_rules() {
5557 } )
5658 . sum ( )
5759 } ;
58- assert_eq ! ( hash, 76353 ) ;
60+ assert_eq ! ( hash, 65720 ) ;
5961}
6062
6163fn macro_rules_fixtures ( ) -> FxHashMap < String , DeclarativeMacro > {
6264 macro_rules_fixtures_tt ( )
6365 . into_iter ( )
66+ . sorted_by_key ( |( id, _) | id. clone ( ) )
6467 . map ( |( id, tt) | ( id, DeclarativeMacro :: parse_macro_rules ( & tt, |_| span:: Edition :: CURRENT ) ) )
6568 . collect ( )
6669}
@@ -93,7 +96,7 @@ fn invocation_fixtures(
9396 let mut seed = 123456789 ;
9497 let mut res = Vec :: new ( ) ;
9598
96- for ( name, it) in rules {
99+ for ( name, it) in rules. iter ( ) . sorted_by_key ( | & ( id , _ ) | id ) {
97100 for rule in it. rules . iter ( ) {
98101 // Generate twice
99102 for _ in 0 ..2 {
0 commit comments