Skip to content
This repository was archived by the owner on Jul 22, 2024. It is now read-only.

Commit d921ed2

Browse files
committed
another opt
1 parent 12c9601 commit d921ed2

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

src/state/mod.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -191,23 +191,22 @@ impl StateDiff {
191191

192192
let mut storage_updates = HashMap::new();
193193

194-
let addresses: Vec<Address> =
195-
get_keys(self.storage_updates.clone(), other.storage_updates.clone());
194+
let addresses: Vec<&Address> = get_keys(&self.storage_updates, &other.storage_updates);
196195

197196
for address in addresses {
198197
let default: HashMap<Felt252, Felt252> = HashMap::new();
199198
let mut map_a = self
200199
.storage_updates
201-
.get(&address)
200+
.get(address)
202201
.unwrap_or(&default)
203202
.to_owned();
204203
let map_b = other
205204
.storage_updates
206-
.get(&address)
205+
.get(address)
207206
.unwrap_or(&default)
208207
.to_owned();
209208
map_a.extend(map_b);
210-
storage_updates.insert(address, map_a.clone());
209+
storage_updates.insert(address.clone(), map_a.clone());
211210
}
212211

213212
StateDiff {

src/utils.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,12 +279,12 @@ pub fn to_cache_state_storage_mapping(
279279

280280
// get a vector of keys from two hashmaps
281281

282-
pub fn get_keys<K, V>(map_a: HashMap<K, V>, map_b: HashMap<K, V>) -> Vec<K>
282+
pub fn get_keys<'a, K, V>(map_a: &'a HashMap<K, V>, map_b: &'a HashMap<K, V>) -> Vec<&'a K>
283283
where
284284
K: Hash + Eq,
285285
{
286-
let mut keys1: HashSet<K> = map_a.into_keys().collect();
287-
let keys2: HashSet<K> = map_b.into_keys().collect();
286+
let mut keys1: HashSet<&K> = map_a.keys().collect();
287+
let keys2: HashSet<&K> = map_b.keys().collect();
288288

289289
keys1.extend(keys2);
290290

0 commit comments

Comments
 (0)