Skip to content

Commit

Permalink
use Default in storage
Browse files Browse the repository at this point in the history
  • Loading branch information
cdump committed Feb 19, 2025
1 parent b9ddbad commit c1e65f0
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/storage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ use crate::{
vm::{StepResult, Vm},
U256, VAL_1, VAL_1_B, VAL_32_B,
},
collections::HashMap,
utils::{and_mask_to_type, elabel, execute_until_function_start, match_first_two},
DynSolType, Selector, Slot,
};
use std::{
cell::RefCell,
collections::{BTreeMap, BTreeSet, HashMap},
collections::{BTreeMap, BTreeSet},
rc::Rc,
};

Expand Down Expand Up @@ -157,16 +158,11 @@ impl std::fmt::Debug for StorageElement {

type SlotHashMap = HashMap<Slot, Vec<Rc<RefCell<StorageElement>>>>;

#[derive(Default)]
struct Storage {
loaded: SlotHashMap,
}
impl Storage {
fn new() -> Self {
Self {
loaded: HashMap::new(),
}
}

fn remove(&mut self, val: &Rc<RefCell<StorageElement>>) {
self.loaded
.get_mut(&val.borrow().slot)
Expand Down Expand Up @@ -616,7 +612,7 @@ fn analyze_one_function(
let calldata = CallDataImpl::<Label>::new(selector, arguments);
let mut vm = Vm::new(code, &calldata);

let mut st = Storage::new();
let mut st = Storage::default();
let mut gas_used = 0;

if !is_fallback {
Expand Down

0 comments on commit c1e65f0

Please sign in to comment.