Avoid pointless work
@@ -99,8 +99,12 @@ impl OverlayedChanges {
/// Commit prospective changes to state.
pub fn commit_prospective(&mut self) {
+ 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.
pub fn drain(&mut self) -> ::std::collections::hash_map::Drain<std::vec::Vec<u8>, std::vec::Vec<u8>> {
