Skip to content

Commit 8b74cfb

Browse files
committed
Improve link name prefix implementation
1 parent 56de10a commit 8b74cfb

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/vm/processor.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ use alloc::{
99
use core::cell::{Cell, RefCell};
1010

1111
use derivative::Derivative;
12-
use itertools::Itertools;
1312
#[allow(unused_imports)]
1413
use num_traits::float::FloatCore;
1514
use replace_with::replace_with_or_default_and_return;
@@ -90,14 +89,14 @@ impl Processor {
9089
// finally, get the link name
9190

9291
// link name prefix, eg "processor"
93-
let split = other.block.name.split('-').collect_vec();
94-
let name_prefix = if split.len() >= 2
95-
&& (split[split.len() - 1] == "large"
96-
|| split[split.len() - 1].parse::<f64>().is_ok())
92+
let mut parts = other.block.name.rsplit('-');
93+
let last_part = parts.next().unwrap_or("");
94+
let name_prefix = if let Some(second_last_part) = parts.next()
95+
&& (last_part == "large" || last_part.parse::<f64>().is_ok())
9796
{
98-
split[split.len() - 2]
97+
second_last_part
9998
} else {
100-
split[split.len() - 1]
99+
last_part
101100
};
102101

103102
// link indices that are already in use for this prefix
@@ -177,7 +176,7 @@ impl Processor {
177176

178177
// set_initial_config assumes the processor is disabled and increments running_processors if it becomes enabled
179178
// so decrement running_processors if the processor is currently enabled to avoid double-counting
180-
let prev_running_processors = Cell::get(&*vm.running_processors);
179+
let prev_running_processors = vm.running_processors.get();
181180
if self.state.enabled {
182181
vm.running_processors.update(|n| n - 1);
183182
}

0 commit comments

Comments
 (0)