Skip to content

Commit 975a456

Browse files
authored
Remove redundant String clones in Sourcify metadata conversion (#12554)
Update external.rs
1 parent 9a39cb7 commit 975a456

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

crates/evm/traces/src/identifier/external.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -462,17 +462,17 @@ struct Compilation {
462462
impl From<SourcifyMetadata> for Metadata {
463463
fn from(metadata: SourcifyMetadata) -> Self {
464464
let SourcifyMetadata { abi, compilation } = metadata;
465+
let (contract_name, compiler_version) = compilation
466+
.map(|c| (c.name, c.compiler_version))
467+
.unwrap_or_else(|| (String::new(), String::new()));
465468
// Defaulted fields may be fetched from sourcify but we don't make use of them.
466469
Self {
467470
source_code: foundry_block_explorers::contract::SourceCodeMetadata::Sources(
468471
Default::default(),
469472
),
470473
abi: Box::<str>::from(abi.unwrap_or_default()).into(),
471-
contract_name: compilation.as_ref().map(|c| c.name.clone()).unwrap_or_default(),
472-
compiler_version: compilation
473-
.as_ref()
474-
.map(|c| c.compiler_version.clone())
475-
.unwrap_or_default(),
474+
contract_name,
475+
compiler_version,
476476
optimization_used: 0,
477477
runs: 0,
478478
constructor_arguments: Default::default(),

0 commit comments

Comments
 (0)