Skip to content

Commit 67d1520

Browse files
authored
Update lib.rs
1 parent a2e4c36 commit 67d1520

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

crates/linking/src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use alloy_primitives::{Address, B256, Bytes};
99
use foundry_compilers::{
1010
Artifact, ArtifactId,
11-
artifacts::{CompactContractBytecodeCow, Libraries},
11+
artifacts::{CompactContractBytecodeCow, Libraries, Offsets},
1212
contracts::ArtifactContracts,
1313
};
1414
use rayon::prelude::*;
@@ -108,22 +108,22 @@ impl<'a> Linker<'a> {
108108
// Deep-merge link references from creation and deployed bytecode.
109109
// This ensures we don't lose libraries when both bytecode objects reference
110110
// libraries under the same source file key but with different library names.
111-
let mut references = BTreeMap::new();
111+
let mut references: BTreeMap<String, BTreeMap<String, Vec<Offsets>>> = BTreeMap::new();
112112
if let Some(bytecode) = &contract.bytecode {
113113
for (file, libs) in &bytecode.link_references {
114-
let entry = references.entry(file.clone()).or_insert_with(BTreeMap::new);
114+
let entry = references.entry(file.clone()).or_default();
115115
for (name, offsets) in libs {
116-
entry.entry(name.clone()).or_insert_with(Vec::new).extend(offsets.clone());
116+
entry.entry(name.clone()).or_default().extend(offsets.clone());
117117
}
118118
}
119119
}
120120
if let Some(deployed_bytecode) = &contract.deployed_bytecode
121121
&& let Some(bytecode) = &deployed_bytecode.bytecode
122122
{
123123
for (file, libs) in &bytecode.link_references {
124-
let entry = references.entry(file.clone()).or_insert_with(BTreeMap::new);
124+
let entry = references.entry(file.clone()).or_default();
125125
for (name, offsets) in libs {
126-
entry.entry(name.clone()).or_insert_with(Vec::new).extend(offsets.clone());
126+
entry.entry(name.clone()).or_default().extend(offsets.clone());
127127
}
128128
}
129129
}

0 commit comments

Comments
 (0)