Move, do not copy, access struct in swallow_commit
@@ -47,14 +47,6 @@ impl Accessed {
self.accessed_storage.insert((storage.0, storage.1));
}
}
-
- fn accessed_addresses(&self) -> alloc::collections::btree_set::Iter<'_, H160> {
- self.accessed_addresses.iter()
- }
-
- fn accessed_storages(&self) -> alloc::collections::btree_set::Iter<'_, (H160, H256)> {
- self.accessed_storage.iter()
- }
}
pub struct StackSubstateMetadata<'config> {
@@ -83,12 +75,17 @@ impl<'config> StackSubstateMetadata<'config> {
self.gasometer.record_stipend(other.gasometer.gas())?;
self.gasometer
.record_refund(other.gasometer.refunded_gas())?;
- if let Some(addresses) = other.accessed_addresses() {
- self.access_addresses(addresses.copied());
- };
- if let Some(storages) = other.accessed_storages() {
- self.access_storages(storages.copied());
- };
+
+ if let (Some(mut other_accessed), Some(self_accessed)) =
+ (other.accessed, self.accessed.as_mut())
+ {
+ self_accessed
+ .accessed_addresses
+ .append(&mut other_accessed.accessed_addresses);
+ self_accessed
+ .accessed_storage
+ .append(&mut other_accessed.accessed_storage);
+ }
Ok(())
}
@@ -160,18 +157,6 @@ impl<'config> StackSubstateMetadata<'config> {
accessed.access_storages(storages);
}
}
-
- fn accessed_addresses(&self) -> Option<alloc::collections::btree_set::Iter<'_, H160>> {
- self.accessed
- .as_ref()
- .map(|accessed| accessed.accessed_addresses())
- }
-
- fn accessed_storages(&self) -> Option<alloc::collections::btree_set::Iter<'_, (H160, H256)>> {
- self.accessed
- .as_ref()
- .map(|accessed| accessed.accessed_storages())
- }
}
#[derive(Debug, Eq, PartialEq, Clone)]
