Skip to content

Commit

Permalink
Use IndexMap::get_index_of
Browse files Browse the repository at this point in the history
Several calls to `IndexMap::get_full` were only using the index, which
can be more directly served by calling `get_index_of`.
  • Loading branch information
cuviper authored and bluss committed Mar 6, 2024
1 parent c30afa9 commit e219ecf
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/graphmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -566,8 +566,8 @@ where
gr.add_node(node);
}
for ((a, b), edge_weight) in self.edges {
let (ai, _, _) = self.nodes.get_full(&a).unwrap();
let (bi, _, _) = self.nodes.get_full(&b).unwrap();
let ai = self.nodes.get_index_of(&a).unwrap();
let bi = self.nodes.get_index_of(&b).unwrap();
gr.add_edge(node_index(ai), node_index(bi), edge_weight);
}
gr
Expand Down Expand Up @@ -1154,8 +1154,7 @@ where
self.node_count()
}
fn to_index(&self, ix: Self::NodeId) -> usize {
let (i, _, _) = self.nodes.get_full(&ix).unwrap();
i
self.nodes.get_index_of(&ix).unwrap()
}
fn from_index(&self, ix: usize) -> Self::NodeId {
assert!(
Expand Down Expand Up @@ -1207,8 +1206,7 @@ where
}

fn to_index(&self, ix: Self::EdgeId) -> usize {
let (i, _, _) = self.edges.get_full(&ix).unwrap();
i
self.edges.get_index_of(&ix).unwrap()
}

fn from_index(&self, ix: usize) -> Self::EdgeId {
Expand Down

0 comments on commit e219ecf

Please sign in to comment.