Skip to content

Commit 5b221fe

Browse files
authored
chore: use get_or_calculate_hash better (#11350)
1 parent 2e1d303 commit 5b221fe

File tree

1 file changed

+2
-15
lines changed

1 file changed

+2
-15
lines changed

crates/evm/coverage/src/inspector.rs

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ where
3939
CTX: ContextTr<Journal: JournalExt>,
4040
{
4141
fn initialize_interp(&mut self, interpreter: &mut Interpreter, _context: &mut CTX) {
42-
get_or_insert_contract_hash(interpreter);
42+
interpreter.bytecode.get_or_calculate_hash();
4343
self.insert_map(interpreter);
4444
}
4545

@@ -61,7 +61,7 @@ impl LineCoverageCollector {
6161
/// See comments on `current_map` for more details.
6262
#[inline]
6363
fn get_or_insert_map(&mut self, interpreter: &mut Interpreter) -> &mut HitMap {
64-
let hash = get_or_insert_contract_hash(interpreter);
64+
let hash = interpreter.bytecode.get_or_calculate_hash();
6565
if self.current_hash != *hash {
6666
self.insert_map(interpreter);
6767
}
@@ -82,16 +82,3 @@ impl LineCoverageCollector {
8282
.into();
8383
}
8484
}
85-
86-
/// Helper function for extracting contract hash used to record coverage hit map.
87-
///
88-
/// If the contract hash is zero (contract not yet created but it's going to be created in current
89-
/// tx) then the hash is calculated from the bytecode.
90-
#[inline]
91-
fn get_or_insert_contract_hash(interpreter: &mut Interpreter) -> B256 {
92-
interpreter
93-
.bytecode
94-
.hash()
95-
.filter(|h| !h.is_zero())
96-
.unwrap_or_else(|| interpreter.bytecode.get_or_calculate_hash())
97-
}

0 commit comments

Comments
 (0)