From: Ian Jackson Date: Thu, 31 Mar 2022 02:11:09 +0000 (+0100) Subject: PlayerUpdates: Rename update log starting functions and types X-Git-Tag: otter-1.0.0~36 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=5637e5034de7bb8382856a63b3f5455141505b3d;p=otter.git PlayerUpdates: Rename update log starting functions and types Prompted by clippy complaining about the old weird new() function. Signed-off-by: Ian Jackson --- diff --git a/src/global.rs b/src/global.rs index 751dbd0a..6b4471c6 100644 --- a/src/global.rs +++ b/src/global.rs @@ -639,7 +639,7 @@ impl<'ig> InstanceGuard<'ig> { Err(ME::AlreadyExists)?; } let player = self.c.g.gs.players.insert(gnew); - let u = PlayerUpdates::new_begin(&self.c.g.gs).new(); + let u = PlayerUpdates::start(&self.c.g.gs).for_player(); let record = PlayerRecord { u, account, ipl: inew, }; self.c.g.iplayers.insert(player, record); @@ -1169,13 +1169,13 @@ impl InstanceGuard<'_> { discard_mismatches(&mut gs.players, &mut aplayers); discard_mismatches(&mut gs.pieces.0, &mut ipieces); - let pu_bc = PlayerUpdates::new_begin(&gs); + let pu_bc = PlayerUpdates::start(&gs); let iplayers: SecondarySlotMap = { let a = aplayers; a.into_iter() }.filter_map(|(player, ipl)| { - let u = pu_bc.new(); + let u = pu_bc.for_player(); let account = accounts.lookup(ipl.acctid).ok()?.0.account.clone(); Some((player, PlayerRecord { u, ipl, account })) }).collect(); diff --git a/src/updates.rs b/src/updates.rs index ecbe6160..51f41f34 100644 --- a/src/updates.rs +++ b/src/updates.rs @@ -357,12 +357,12 @@ impl StableIndexOffset for UpdateId { // ---------- prepared updates, queued in memory ---------- -pub struct PlayerUpdatesBuildContext { +pub struct PlayerUpdatesStartContext { pub(self) u1: Arc, } -impl PlayerUpdatesBuildContext { - pub fn new(&self) -> PlayerUpdates { +impl PlayerUpdatesStartContext { + pub fn for_player(&self) -> PlayerUpdates { let mut log = StableIndexVecDeque::with_capacity(50); log.push_back(self.u1.clone()); let cv = default(); @@ -371,13 +371,13 @@ impl PlayerUpdatesBuildContext { } impl PlayerUpdates { - pub fn new_begin(gs: &GameState) -> PlayerUpdatesBuildContext { + pub fn start(gs: &GameState) -> PlayerUpdatesStartContext { let u1 = Arc::new(PreparedUpdate { gen: gs.gen, when: Instant::now(), us: vec![], }); - PlayerUpdatesBuildContext { u1 } + PlayerUpdatesStartContext { u1 } } pub fn push>>(&mut self, update: U) {