@@ -330,16 +330,11 @@ pub mod pallet {
330
330
} ) ;
331
331
332
332
// compute actual dispatch weight that depends on the stored message size
333
- let maximal_increase_message_fee = T :: WeightInfo :: maximal_increase_message_fee ( ) ;
334
- let current_increase_message_fee =
335
- T :: WeightInfo :: increase_message_fee ( message_size as _ ) ;
336
- let actual_weight = if maximal_increase_message_fee. ref_time ( ) <
337
- current_increase_message_fee. ref_time ( )
338
- {
339
- maximal_increase_message_fee
340
- } else {
341
- current_increase_message_fee
342
- } ;
333
+ let actual_weight = sp_std:: cmp:: min_by (
334
+ T :: WeightInfo :: maximal_increase_message_fee ( ) ,
335
+ T :: WeightInfo :: increase_message_fee ( message_size as _ ) ,
336
+ |w1, w2| w1. ref_time ( ) . cmp ( & w2. ref_time ( ) ) ,
337
+ ) ;
343
338
344
339
Ok ( PostDispatchInfo { actual_weight : Some ( actual_weight) , pays_fee : Pays :: Yes } )
345
340
}
@@ -459,11 +454,10 @@ pub mod pallet {
459
454
ReceivalResult :: TooManyUnconfirmedMessages => ( dispatch_weight, true ) ,
460
455
} ;
461
456
462
- let unspent_weight = if unspent_weight. ref_time ( ) < dispatch_weight. ref_time ( ) {
463
- unspent_weight
464
- } else {
465
- dispatch_weight
466
- } ;
457
+ let unspent_weight =
458
+ sp_std:: cmp:: min_by ( unspent_weight, dispatch_weight, |w1, w2| {
459
+ w1. ref_time ( ) . cmp ( & w2. ref_time ( ) )
460
+ } ) ;
467
461
dispatch_weight_left -= dispatch_weight - unspent_weight;
468
462
actual_weight = actual_weight. saturating_sub ( unspent_weight) . saturating_sub (
469
463
// delivery call weight formula assumes that the fee is paid at
0 commit comments