From: Ian Jackson Date: Thu, 1 Apr 2021 10:04:42 +0000 (+0100) Subject: cmd updates: Refactor AddPieces handling X-Git-Tag: otter-0.5.0~336 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=cd017e7c36411b35d8902ac16807642ba724e8c7;p=otter.git cmd updates: Refactor AddPieces handling This makes it more like the other places in its local variable names. Signed-off-by: Ian Jackson --- diff --git a/daemon/cmdlistener.rs b/daemon/cmdlistener.rs index 54d9300a..926cfe6c 100644 --- a/daemon/cmdlistener.rs +++ b/daemon/cmdlistener.rs @@ -871,17 +871,19 @@ fn execute_for_game<'cs, 'igr, 'ig: 'igr>( for insn in insns.drain(0..) { trace_dbg!("exeucting game insns", insn); - if let (MGI::AddPieces{..}, - &mut Some(St { ref mut uh, auth, have_deleted: true })) - = (&insn, &mut uh_auth) - { - // This makes sure that all the updates we have queued up - // talking about the old PieceId, will be Prepared (ie, the - // vpid lookup done) before we reuse the slot and render the - // vpid lookup impossible. - let ig = igu.by_mut(auth); - mem::replace(uh, mk_uh()).complete(ig, &who)?; - }; + if_chain!{ + if let MGI::AddPieces{..} = &insn; + if let Some(st) = &mut uh_auth; + if st.have_deleted == true; + then { + // This makes sure that all the updates we have queued up + // talking about the old PieceId, will be Prepared (ie, the + // vpid lookup done) before we reuse the slot and render the + // vpid lookup impossible. + let ig = igu.by_mut(st.auth); + mem::replace(&mut st.uh, mk_uh()).complete(ig, &who)?; + } + } let was_delete = matches!(&insn, MGI::DeletePiece(..)); let (updates, resp, unprepared, ig) =