Avoid pointless work

This commit is contained in:
Gav
2018-02-13 18:00:21 +01:00
parent 41ea39662d
commit 793acd9a1c
+5 -1
View File
@@ -99,7 +99,11 @@ impl OverlayedChanges {
/// Commit prospective changes to state.
pub fn commit_prospective(&mut self) {
self.committed.update(self.prospective.storage.drain());
if self.committed.storage.is_empty() {
::std::mem::swap(&mut self.prospective, &mut self.committed);
} else {
self.committed.update(self.prospective.storage.drain());
}
}
/// Drain prospective changes to an iterator.