chiark / gitweb /
cmd updates: Refactor AddPieces handling
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 1 Apr 2021 10:04:42 +0000 (11:04 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 1 Apr 2021 10:38:14 +0000 (11:38 +0100)
This makes it more like the other places in its local variable names.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
daemon/cmdlistener.rs

index 54d9300a9f0b5ac15ede8b520c8150cadce6777f..926cfe6ceb8af881dd40f4e700afcb6239b6c7f8 100644 (file)
@@ -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) =