|
8 | 8 | use alloy_primitives::{Address, B256, Bytes};
|
9 | 9 | use foundry_compilers::{
|
10 | 10 | Artifact, ArtifactId,
|
11 |
| - artifacts::{CompactContractBytecodeCow, Libraries}, |
| 11 | + artifacts::{CompactContractBytecodeCow, Libraries, Offsets}, |
12 | 12 | contracts::ArtifactContracts,
|
13 | 13 | };
|
14 | 14 | use rayon::prelude::*;
|
@@ -108,22 +108,22 @@ impl<'a> Linker<'a> {
|
108 | 108 | // Deep-merge link references from creation and deployed bytecode.
|
109 | 109 | // This ensures we don't lose libraries when both bytecode objects reference
|
110 | 110 | // 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(); |
112 | 112 | if let Some(bytecode) = &contract.bytecode {
|
113 | 113 | 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(); |
115 | 115 | 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()); |
117 | 117 | }
|
118 | 118 | }
|
119 | 119 | }
|
120 | 120 | if let Some(deployed_bytecode) = &contract.deployed_bytecode
|
121 | 121 | && let Some(bytecode) = &deployed_bytecode.bytecode
|
122 | 122 | {
|
123 | 123 | 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(); |
125 | 125 | 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()); |
127 | 127 | }
|
128 | 128 | }
|
129 | 129 | }
|
|
0 commit comments