Skip to content

Commit aa43630

Browse files
committed
store: Make ManifestIdxMap::new a little more efficient
1 parent 6e6ea3b commit aa43630

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

store/postgres/src/dynds/private.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -331,17 +331,14 @@ struct ManifestIdxMap {
331331

332332
impl ManifestIdxMap {
333333
fn new(src: &[(i32, String)], dst: &[(i32, String)]) -> Self {
334+
let dst_idx_map: HashMap<&String, i32> =
335+
HashMap::from_iter(dst.iter().map(|(idx, name)| (name, *idx)));
334336
let map = src
335337
.iter()
336338
.map(|(src_idx, src_name)| {
337339
(
338340
*src_idx,
339-
(
340-
dst.iter()
341-
.find(|(_, dst_name)| src_name == dst_name)
342-
.map(|(dst_idx, _)| *dst_idx),
343-
src_name.to_string(),
344-
),
341+
(dst_idx_map.get(src_name).copied(), src_name.to_string()),
345342
)
346343
})
347344
.collect();

0 commit comments

Comments
 (0)