@@ -1716,7 +1716,11 @@ macro_rules! process_events_body {
1716
1716
1717
1717
let _single_processor = $self. pending_events_processor. lock( ) . unwrap( ) ;
1718
1718
loop {
1719
+ #[ cfg( debug_assertions) ]
1719
1720
let mut next_event = $self. pending_events. lock( ) . unwrap( ) . front( ) . map( |ev| ( * ev) . clone( ) ) ;
1721
+ #[ cfg( not( debug_assertions) ) ]
1722
+ let mut next_event = $self. pending_events. lock( ) . unwrap( ) . pop_front( ) ;
1723
+
1720
1724
let mut post_event_actions = Vec :: new( ) ;
1721
1725
loop {
1722
1726
if let Some ( ( event, action_opt) ) = next_event {
@@ -1727,20 +1731,23 @@ macro_rules! process_events_body {
1727
1731
}
1728
1732
$event_to_handle = event;
1729
1733
$handle_event;
1730
- let mut pending_events = $self. pending_events. lock( ) . unwrap( ) ;
1731
- // We're required to take the `pending_events_processor` lock any time we
1732
- // remove from `pending_events`, however have no general way to enforce that.
1733
- // Instead, here, we assert that the next event hasn't changed out from under
1734
- // us.
1735
1734
#[ cfg( debug_assertions) ] {
1735
+ let mut pending_events = $self. pending_events. lock( ) . unwrap( ) ;
1736
+ // We're required to take the `pending_events_processor` lock any time we
1737
+ // remove from `pending_events`, however have no general way to enforce that.
1738
+ // Instead, here, we assert that the next event hasn't changed out from under
1739
+ // us.
1736
1740
debug_assert_eq!( _ev_clone, pending_events. front( ) . unwrap( ) . 0 ) ;
1741
+ debug_assert_eq!( action_opt, pending_events. front( ) . unwrap( ) . 1 ) ;
1742
+ pending_events. pop_front( ) ;
1743
+ next_event = pending_events. front( ) . map( |ev| ev. clone( ) ) ;
1744
+ }
1745
+ #[ cfg( not( debug_assertions) ) ] {
1746
+ next_event = pending_events. pop_front( ) ;
1737
1747
}
1738
- debug_assert_eq!( action_opt, pending_events. front( ) . unwrap( ) . 1 ) ;
1739
1748
if let Some ( action) = action_opt {
1740
1749
post_event_actions. push( action) ;
1741
1750
}
1742
- pending_events. pop_front( ) ;
1743
- next_event = pending_events. front( ) . map( |ev| ev. clone( ) ) ;
1744
1751
} else {
1745
1752
break ;
1746
1753
}
0 commit comments