From: Ian Jackson Date: Sun, 14 Mar 2021 19:12:06 +0000 (+0000) Subject: Refactor: Break out pri.map_piece_update_op X-Git-Tag: otter-0.4.0~65 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=82f8ab300b6c102310bcaae8ab0982fadcbbb302;p=otter.git Refactor: Break out pri.map_piece_update_op Signed-off-by: Ian Jackson --- diff --git a/src/pcrender.rs b/src/pcrender.rs index e1f8301d..6cbb015f 100644 --- a/src/pcrender.rs +++ b/src/pcrender.rs @@ -35,6 +35,23 @@ impl VisiblePieceAngle { } impl PieceRenderInstructions { + #[throws(IE)] + pub fn map_piece_update_op(&self, ioccults: &IOccults, + gpc: &GPiece, ipc: &IPiece, + op: PieceUpdateOp<(),()> + ) -> PieceUpdateOp + { + op.try_map( + |()|{ + let ns = self.prep_piecestate(ioccults, gpc, ipc)?; + >::Ok(ns) + }, + |()|{ + Ok(gpc.zlevel.clone()) + } + )? + } + #[throws(IE)] pub fn prep_piecestate(&self, ioccults: &IOccults, gpc: &GPiece, ipc: &IPiece) diff --git a/src/updates.rs b/src/updates.rs index 16233ce9..b6eb9013 100644 --- a/src/updates.rs +++ b/src/updates.rs @@ -506,15 +506,7 @@ impl<'r> PrepareUpdatesBuffer<'r> { max_z.update_max(&gpc.zlevel.z); - let op = op.try_map( - |()|{ - let ns = pri.prep_piecestate(ioccults, gpc, ipc)?; - >::Ok(ns) - }, - |()|{ - Ok(gpc.zlevel.clone()) - } - )?; + let op = pri.map_piece_update_op(ioccults, gpc, ipc, op)?; Some(PreparedPieceUpdate { piece: pri.vpid,