From: Ian Jackson Date: Wed, 31 Mar 2021 17:21:49 +0000 (+0100) Subject: cmd updates: In UpdateHandlerBulk, use a HashMap not a SlotMap X-Git-Tag: otter-0.5.0~349 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=9505d26132f822a834a4ce57b6ae995898be3479;p=otter.git cmd updates: In UpdateHandlerBulk, use a HashMap not a SlotMap Otherwise if a slot gets reused, this can go wrong. It is easier to do this than think about whether the separation of inserts from deletes would be sufficient. Signed-off-by: Ian Jackson --- diff --git a/daemon/cmdlistener.rs b/daemon/cmdlistener.rs index 371f9e80..bcffb751 100644 --- a/daemon/cmdlistener.rs +++ b/daemon/cmdlistener.rs @@ -923,7 +923,7 @@ fn execute_for_game<'cs, 'igr, 'ig: 'igr>( #[derive(Debug,Default)] struct UpdateHandlerBulk { - pieces: slotmap::SparseSecondaryMap>, + pieces: HashMap>, logs: bool, raw: Vec, } @@ -952,7 +952,7 @@ impl UpdateHandler { Bulk(bulk) => { for (upiece, uuop) in updates.pcs { use PieceUpdateOp::*; - let oe = bulk.pieces.get(upiece); + let oe = bulk.pieces.get(&upiece); let ne = match (oe, uuop) { ( None , e ) => Some( e ), ( Some( Insert(()) ) , Delete() ) => None, @@ -963,7 +963,7 @@ impl UpdateHandler { trace_dbg!("accumulate", upiece, oe, uuop, ne); match ne { Some(ne) => { bulk.pieces.insert(upiece, ne); }, - None => { bulk.pieces.remove(upiece); }, + None => { bulk.pieces.remove(&upiece); }, }; } bulk.logs |= updates.log.len() != 0;