chiark / gitweb /
PlayerUpdates: Rename update log starting functions and types
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 31 Mar 2022 02:11:09 +0000 (03:11 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 31 Mar 2022 02:11:09 +0000 (03:11 +0100)
Prompted by clippy complaining about the old weird new() function.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/global.rs
src/updates.rs

index 751dbd0aff38f1a15d9e5f2b38779453f96467de..6b4471c6ce9b50a07588f7d02b7700d98e7b579a 100644 (file)
@@ -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<PlayerId, PlayerRecord> = {
       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();
index ecbe6160c3ced4009a434c768d6bab98c875d35b..51f41f34ea7a4db4f3f1068c8eb7a1bbd1e98e56 100644 (file)
@@ -357,12 +357,12 @@ impl StableIndexOffset for UpdateId {
 
 // ---------- prepared updates, queued in memory ----------
 
-pub struct PlayerUpdatesBuildContext {
+pub struct PlayerUpdatesStartContext {
   pub(self) u1: Arc<PreparedUpdate>,
 }
 
-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<U: Into<Arc<PreparedUpdate>>>(&mut self, update: U) {