Minor performance optimization
This commit is contained in:
parent
4d67a5480f
commit
9ec5e10c0b
1 changed files with 6 additions and 3 deletions
|
|
@ -1,5 +1,3 @@
|
|||
use std::collections::HashSet;
|
||||
|
||||
#[derive(Debug)]
|
||||
struct Vertex {
|
||||
name: u16,
|
||||
|
|
@ -50,7 +48,12 @@ impl Graph {
|
|||
|
||||
for &e in &vertex.edges {
|
||||
let i = self.index[e as usize];
|
||||
self.vertices[i as usize].edges.retain(|&o| o != v);
|
||||
let p = self.vertices[i as usize]
|
||||
.edges
|
||||
.iter()
|
||||
.position(|&o| o == v)
|
||||
.unwrap();
|
||||
self.vertices[i as usize].edges.swap_remove(p);
|
||||
}
|
||||
// dbg!(&self.index);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue