mirror of https://codeberg.org/topola/topola.git
refactor(specctra/design): avoid double-lookup into net_outs
This commit is contained in:
parent
fc9c8c3396
commit
1879d74fac
|
|
@ -3,7 +3,7 @@
|
|||
//! exporting the session file
|
||||
|
||||
use geo::{point, Point, Rotate};
|
||||
use std::collections::HashMap;
|
||||
use std::collections::{hash_map::Entry as HashMapEntry, HashMap};
|
||||
|
||||
use crate::{
|
||||
board::{mesadata::AccessMesadata, Board},
|
||||
|
|
@ -136,26 +136,23 @@ impl SpecctraDesign {
|
|||
},
|
||||
};
|
||||
|
||||
if let Some(net) = net_outs.get_mut(&net) {
|
||||
net.wire.push(wire);
|
||||
} else {
|
||||
net_outs.insert(
|
||||
net,
|
||||
structure::NetOut {
|
||||
name: mesadata
|
||||
.net_netname(net)
|
||||
.ok_or_else(|| {
|
||||
std::io::Error::new(
|
||||
std::io::ErrorKind::InvalidData,
|
||||
format!("tried to reference invalid net ID {}", net),
|
||||
)
|
||||
})?
|
||||
.to_owned(),
|
||||
wire: vec![wire],
|
||||
via: Vec::new(),
|
||||
},
|
||||
);
|
||||
}
|
||||
let net_out = match net_outs.entry(net) {
|
||||
HashMapEntry::Occupied(occ) => occ.into_mut(),
|
||||
HashMapEntry::Vacant(vac) => vac.insert(structure::NetOut {
|
||||
name: mesadata
|
||||
.net_netname(net)
|
||||
.ok_or_else(|| {
|
||||
std::io::Error::new(
|
||||
std::io::ErrorKind::InvalidData,
|
||||
format!("tried to reference invalid net ID {}", net),
|
||||
)
|
||||
})?
|
||||
.to_owned(),
|
||||
wire: Vec::new(),
|
||||
via: Vec::new(),
|
||||
}),
|
||||
};
|
||||
net_out.wire.push(wire);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue