@@ -43,9 +43,11 @@ fn bench_simple_format(b: &mut Bencher) {
43
43
let mut ctx = MessageContext :: new ( & [ "x-testing" ] ) ;
44
44
ctx. add_messages ( & source) ;
45
45
46
- b. iter ( || for id in & ids {
47
- if let Some ( message) = ctx. get_message ( id. as_str ( ) ) {
48
- let _value = ctx. format ( message, None ) ;
46
+ b. iter ( || {
47
+ for id in & ids {
48
+ if let Some ( message) = ctx. get_message ( id. as_str ( ) ) {
49
+ let _value = ctx. format ( message, None ) ;
50
+ }
49
51
}
50
52
} ) ;
51
53
}
@@ -74,18 +76,20 @@ fn bench_menubar_format(b: &mut Bencher) {
74
76
let mut ctx = MessageContext :: new ( & [ "x-testing" ] ) ;
75
77
ctx. add_messages ( & source) ;
76
78
77
- b. iter ( || for id in & ids {
78
- // In real-life usage we'd have different fallback strategies for missing messages
79
- // depending on the type of the widget this message was supposed to translate. Some
80
- // widgets may only expect attributes and they shouldn't be forced to display a value.
81
- // Here however it doesn't matter because we know for certain that the message for `id`
82
- // exists.
83
- if let Some ( message) = ctx. get_message ( id. as_str ( ) ) {
84
- let _value = ctx. format ( message, None ) ;
85
-
86
- if let Some ( ref attributes) = message. attributes {
87
- for attr in attributes {
88
- let _value = ctx. format ( attr, None ) ;
79
+ b. iter ( || {
80
+ for id in & ids {
81
+ // In real-life usage we'd have different fallback strategies for missing messages
82
+ // depending on the type of the widget this message was supposed to translate. Some
83
+ // widgets may only expect attributes and they shouldn't be forced to display a value.
84
+ // Here however it doesn't matter because we know for certain that the message for `id`
85
+ // exists.
86
+ if let Some ( message) = ctx. get_message ( id. as_str ( ) ) {
87
+ let _value = ctx. format ( message, None ) ;
88
+
89
+ if let Some ( ref attributes) = message. attributes {
90
+ for attr in attributes {
91
+ let _value = ctx. format ( attr, None ) ;
92
+ }
89
93
}
90
94
}
91
95
}
0 commit comments