refactor(specctra/design): avoid double-lookup into net_outs

This commit is contained in:
Alain Emilia Anna Zscheile 2024-12-11 00:24:57 +01:00
parent fc9c8c3396
commit 1879d74fac
1 changed files with 18 additions and 21 deletions

View File

@ -3,7 +3,7 @@
//! exporting the session file //! exporting the session file
use geo::{point, Point, Rotate}; use geo::{point, Point, Rotate};
use std::collections::HashMap; use std::collections::{hash_map::Entry as HashMapEntry, HashMap};
use crate::{ use crate::{
board::{mesadata::AccessMesadata, Board}, board::{mesadata::AccessMesadata, Board},
@ -136,12 +136,9 @@ impl SpecctraDesign {
}, },
}; };
if let Some(net) = net_outs.get_mut(&net) { let net_out = match net_outs.entry(net) {
net.wire.push(wire); HashMapEntry::Occupied(occ) => occ.into_mut(),
} else { HashMapEntry::Vacant(vac) => vac.insert(structure::NetOut {
net_outs.insert(
net,
structure::NetOut {
name: mesadata name: mesadata
.net_netname(net) .net_netname(net)
.ok_or_else(|| { .ok_or_else(|| {
@ -151,11 +148,11 @@ impl SpecctraDesign {
) )
})? })?
.to_owned(), .to_owned(),
wire: vec![wire], wire: Vec::new(),
via: Vec::new(), via: Vec::new(),
}, }),
); };
} net_out.wire.push(wire);
} }
} }