@@ -38,20 +38,23 @@ fn get_ids(res: &FluentResource) -> Vec<String> {
3838 . collect ( )
3939}
4040
41- fn get_args ( name : & str ) -> Option < HashMap < & ' static str , FluentValue > > {
41+ fn get_args ( name : & str ) -> Option < HashMap < String , FluentValue > > {
4242 match name {
4343 "preferences" => {
4444 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+ ) ;
5558 Some ( prefs_args)
5659 }
5760 _ => None ,
@@ -91,7 +94,14 @@ fn resolver_bench(c: &mut Criterion) {
9194
9295 b. iter ( || {
9396 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+ }
95105 assert ! ( errors. len( ) == 0 , "Resolver errors: {:#?}" , errors) ;
96106 }
97107 } )
0 commit comments