From: Ian Jackson Date: Fri, 31 Jul 2020 21:31:41 +0000 (+0100) Subject: break out PlayerUpdates.push nfc X-Git-Tag: otter-0.2.0~1218 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=3bdac6df3946e96e8cfa52cf605c92983c689474;p=otter.git break out PlayerUpdates.push nfc --- diff --git a/src/updates.rs b/src/updates.rs index 367a838f..b33142d4 100644 --- a/src/updates.rs +++ b/src/updates.rs @@ -90,6 +90,13 @@ impl Default for PlayerUpdates { } } } +impl PlayerUpdates { + fn push>>(&mut self, update: U) { + self.log.push_back(update.into()); + self.cv.notify_all(); + } +} + impl PreparedUpdate { pub fn json_len(&self) -> usize { self.us.iter().map(|u| 20 + u.json_len()).sum() @@ -266,8 +273,7 @@ impl<'r> Drop for PrepareUpdatesBuffer<'r> { eprintln!("UPDATE {:?}", &update); for (_tplayer, tplupdates) in &mut self.g.updates { - tplupdates.log.push_back(update.clone()); - tplupdates.cv.notify_all(); + tplupdates.push(update.clone()); } } }