3
3
use intern:: Symbol ;
4
4
use rustc_hash:: FxHashMap ;
5
5
use span:: { Edition , Span } ;
6
+ use stdx:: itertools:: Itertools ;
6
7
use syntax:: {
7
8
ast:: { self , HasName } ,
8
9
AstNode ,
@@ -27,9 +28,10 @@ fn benchmark_parse_macro_rules() {
27
28
let hash: usize = {
28
29
let _pt = bench ( "mbe parse macro rules" ) ;
29
30
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 ( )
33
35
} )
34
36
. sum ( )
35
37
} ;
@@ -55,12 +57,13 @@ fn benchmark_expand_macro_rules() {
55
57
} )
56
58
. sum ( )
57
59
} ;
58
- assert_eq ! ( hash, 76353 ) ;
60
+ assert_eq ! ( hash, 65720 ) ;
59
61
}
60
62
61
63
fn macro_rules_fixtures ( ) -> FxHashMap < String , DeclarativeMacro > {
62
64
macro_rules_fixtures_tt ( )
63
65
. into_iter ( )
66
+ . sorted_by_key ( |( id, _) | id. clone ( ) )
64
67
. map ( |( id, tt) | ( id, DeclarativeMacro :: parse_macro_rules ( & tt, |_| span:: Edition :: CURRENT ) ) )
65
68
. collect ( )
66
69
}
@@ -93,7 +96,7 @@ fn invocation_fixtures(
93
96
let mut seed = 123456789 ;
94
97
let mut res = Vec :: new ( ) ;
95
98
96
- for ( name, it) in rules {
99
+ for ( name, it) in rules. iter ( ) . sorted_by_key ( | & ( id , _ ) | id ) {
97
100
for rule in it. rules . iter ( ) {
98
101
// Generate twice
99
102
for _ in 0 ..2 {
0 commit comments