Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
avoid some clones
  • Loading branch information
drahnr committed May 31, 2022
commit a60a3ba4c315a9e095e2bc682dee061e4b79c8c6
14 changes: 8 additions & 6 deletions node/orchestra/proc-macro/src/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ pub(crate) struct ConnectionGraph<'a> {
pub(crate) cycles: Vec<Vec<NodeIndex>>,
/// Messages that are never being sent (and by which subsystem), but are consumed
/// Maps the message `Path` to the subsystem `Ident` represented by `NodeIndex`.
pub(crate) unsent_messages: HashMap<&'a Path, (Ident, NodeIndex)>,
pub(crate) unsent_messages: HashMap<&'a Path, (&'a Ident, NodeIndex)>,
/// Messages being sent (and by which subsystem), but not consumed by any subsystem
/// Maps the message `Path` to the subsystem `Ident` represented by `NodeIndex`.
pub(crate) unconsumed_messages: HashMap<&'a Path, Vec<(Ident, NodeIndex)>>,
pub(crate) unconsumed_messages: HashMap<&'a Path, Vec<(&'a Ident, NodeIndex)>>,
}

impl<'a> ConnectionGraph<'a> {
Expand All @@ -47,9 +47,9 @@ impl<'a> ConnectionGraph<'a> {
// create a directed graph with all the subsystems as nodes and the messages as edges
// key is always the message path, values are node indices in the graph and the subsystem generic identifier
// store the message path and the source sender, both in the graph as well as identifier
let mut outgoing_lut = HashMap::<&Path, Vec<(Ident, NodeIndex)>>::with_capacity(128);
let mut outgoing_lut = HashMap::<&Path, Vec<(&Ident, NodeIndex)>>::with_capacity(128);
// same for consuming the incoming messages
let mut consuming_lut = HashMap::<&Path, (Ident, NodeIndex)>::with_capacity(128);
let mut consuming_lut = HashMap::<&Path, (&Ident, NodeIndex)>::with_capacity(128);

let mut graph = Graph::<Ident, Path>::new();

Expand All @@ -60,9 +60,11 @@ impl<'a> ConnectionGraph<'a> {
outgoing_lut
.entry(outgoing)
.or_default()
.push((ssf.generic.clone(), node_index));
.push((&ssf.generic, node_index));
}
if let Some(_first_consument) = consuming_lut.insert(&ssf.message_to_consume, (&ssf.generic, node_index)) {
// bail, two subsystems consuming the same message
}
consuming_lut.insert(&ssf.message_to_consume, (ssf.generic.clone(), node_index));
}

for (message_ty, (_consuming_subsystem_ident, consuming_node_index)) in consuming_lut.iter()
Expand Down