Skip to content

Commit 7569db7

Browse files
committed
Ensure block exists before removal
1 parent dd9a779 commit 7569db7

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/ops.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2847,17 +2847,17 @@ impl Program {
28472847
}
28482848

28492849
pub fn unregister_block(&mut self, name:String) {
2850-
let block_ix = self.block_info.block_names.remove(&name).unwrap();
2851-
let block = self.block_info.blocks.remove(block_ix);
2852-
2853-
for (pipe_ix, pipe) in block.pipes.iter().enumerate() {
2854-
for shape in block.shapes[pipe_ix].iter() {
2855-
match shape {
2856-
&PipeShape::Scan(e, a, v) => {
2857-
self.block_info.pipe_lookup.get_mut(&(e, a, v)).unwrap().remove_item(pipe);
2858-
},
2859-
&PipeShape::Intermediate(id) => {
2860-
self.block_info.intermediate_pipe_lookup.get_mut(&id).unwrap().remove_item(pipe);
2850+
if let Some(block_ix) = self.block_info.block_names.remove(&name) {
2851+
let block = self.block_info.blocks.remove(block_ix);
2852+
for (pipe_ix, pipe) in block.pipes.iter().enumerate() {
2853+
for shape in block.shapes[pipe_ix].iter() {
2854+
match shape {
2855+
&PipeShape::Scan(e, a, v) => {
2856+
self.block_info.pipe_lookup.get_mut(&(e, a, v)).unwrap().remove_item(pipe);
2857+
},
2858+
&PipeShape::Intermediate(id) => {
2859+
self.block_info.intermediate_pipe_lookup.get_mut(&id).unwrap().remove_item(pipe);
2860+
}
28612861
}
28622862
}
28632863
}

0 commit comments

Comments
 (0)