@@ -38,20 +38,23 @@ fn get_ids(res: &FluentResource) -> Vec<String> {
38
38
. collect ( )
39
39
}
40
40
41
- fn get_args ( name : & str ) -> Option < HashMap < & ' static str , FluentValue > > {
41
+ fn get_args ( name : & str ) -> Option < HashMap < String , FluentValue > > {
42
42
match name {
43
43
"preferences" => {
44
44
let mut prefs_args = HashMap :: new ( ) ;
45
- prefs_args. insert ( "name" , FluentValue :: from ( "John" ) ) ;
46
- prefs_args. insert ( "tabCount" , FluentValue :: from ( 5 ) ) ;
47
- prefs_args. insert ( "count" , FluentValue :: from ( 3 ) ) ;
48
- prefs_args. insert ( "version" , FluentValue :: from ( "65.0" ) ) ;
49
- prefs_args. insert ( "path" , FluentValue :: from ( "/tmp" ) ) ;
50
- prefs_args. insert ( "num" , FluentValue :: from ( 4 ) ) ;
51
- prefs_args
. insert ( "email" , FluentValue :: from ( "[email protected] " ) ) ;
52
- prefs_args. insert ( "value" , FluentValue :: from ( 4.5 ) ) ;
53
- prefs_args. insert ( "unit" , FluentValue :: from ( "mb" ) ) ;
54
- prefs_args. insert ( "service-name" , FluentValue :: from ( "Mozilla Disk" ) ) ;
45
+ prefs_args. insert ( "name" . to_string ( ) , FluentValue :: from ( "John" ) ) ;
46
+ prefs_args. insert ( "tabCount" . to_string ( ) , FluentValue :: from ( 5 ) ) ;
47
+ prefs_args. insert ( "count" . to_string ( ) , FluentValue :: from ( 3 ) ) ;
48
+ prefs_args. insert ( "version" . to_string ( ) , FluentValue :: from ( "65.0" ) ) ;
49
+ prefs_args. insert ( "path" . to_string ( ) , FluentValue :: from ( "/tmp" ) ) ;
50
+ prefs_args. insert ( "num" . to_string ( ) , FluentValue :: from ( 4 ) ) ;
51
+ prefs_args
. insert ( "email" . to_string ( ) , FluentValue :: from ( "[email protected] " ) ) ;
52
+ prefs_args. insert ( "value" . to_string ( ) , FluentValue :: from ( 4.5 ) ) ;
53
+ prefs_args. insert ( "unit" . to_string ( ) , FluentValue :: from ( "mb" ) ) ;
54
+ prefs_args. insert (
55
+ "service-name" . to_string ( ) ,
56
+ FluentValue :: from ( "Mozilla Disk" ) ,
57
+ ) ;
55
58
Some ( prefs_args)
56
59
}
57
60
_ => None ,
@@ -91,7 +94,14 @@ fn resolver_bench(c: &mut Criterion) {
91
94
92
95
b. iter ( || {
93
96
for id in & ids {
94
- let ( _msg, errors) = bundle. compound ( id, args. as_ref ( ) ) . expect ( "Message found" ) ;
97
+ let msg = bundle. get_message ( id) . expect ( "Message found" ) ;
98
+ let mut errors = vec ! [ ] ;
99
+ if let Some ( value) = msg. value {
100
+ let _ = bundle. format_pattern ( value, args. as_ref ( ) , & mut errors) ;
101
+ }
102
+ for ( _, value) in msg. attributes {
103
+ let _ = bundle. format_pattern ( value, args. as_ref ( ) , & mut errors) ;
104
+ }
95
105
assert ! ( errors. len( ) == 0 , "Resolver errors: {:#?}" , errors) ;
96
106
}
97
107
} )
0 commit comments