@@ -195,18 +195,6 @@ pub enum PaymentError {
195195
196196type PaymentEntry < ' a > = hash_map:: OccupiedEntry < ' a , PaymentHash , usize > ;
197197
198- macro_rules! look_up_or_insert {
199- ( $payment_cache: ident, $payment_hash: expr) => {
200- loop {
201- let entry = $payment_cache. entry( $payment_hash) ;
202- match entry {
203- hash_map:: Entry :: Occupied ( entry) => break entry,
204- hash_map:: Entry :: Vacant ( entry) => entry. insert( 0 ) ,
205- } ;
206- } ;
207- }
208- }
209-
210198impl < P : Deref , R , S : Deref , L : Deref , E > InvoicePayer < P , R , S , L , E >
211199where
212200 P :: Target : Payer ,
@@ -271,7 +259,14 @@ where
271259 let mut payment_cache = self . payment_cache . lock ( ) . unwrap ( ) ;
272260 let mut entry = match payment_cache. entry ( payment_hash) {
273261 hash_map:: Entry :: Occupied ( _) => return Err ( PaymentError :: Invoice ( "payment pending" ) ) ,
274- hash_map:: Entry :: Vacant ( _) => look_up_or_insert ! ( payment_cache, payment_hash) ,
262+ hash_map:: Entry :: Vacant ( entry) => {
263+ // TODO: Replace with hash_map::Entry::insert once no longer experimental
264+ entry. insert ( 0 ) ;
265+ match payment_cache. entry ( payment_hash) {
266+ hash_map:: Entry :: Occupied ( entry) => entry,
267+ hash_map:: Entry :: Vacant ( _) => unreachable ! ( ) ,
268+ }
269+ } ,
275270 } ;
276271
277272 let payment_secret = Some ( invoice. payment_secret ( ) . clone ( ) ) ;
@@ -428,7 +423,12 @@ where
428423 }
429424
430425 let mut payment_cache = self . payment_cache . lock ( ) . unwrap ( ) ;
431- let mut entry = look_up_or_insert ! ( payment_cache, * payment_hash) ;
426+ let mut entry = loop {
427+ match payment_cache. entry ( * payment_hash) {
428+ hash_map:: Entry :: Occupied ( entry) => break entry,
429+ hash_map:: Entry :: Vacant ( entry) => entry. insert ( 0 ) ,
430+ } ;
431+ } ;
432432
433433 if * rejected_by_dest {
434434 log_trace ! ( self . logger, "Payment {} rejected by destination; not retrying" , log_bytes!( payment_hash. 0 ) ) ;
0 commit comments