Bring back proper consecutive register reuser
This commit is contained in:
parent
28e1b43b81
commit
954b8417b3
@ -47,6 +47,22 @@ impl LocalCounter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn consecutive(&mut self, amount: usize) -> Vec<u16> {
|
pub fn consecutive(&mut self, amount: usize) -> Vec<u16> {
|
||||||
|
'outer: for free_num in self.1.clone() {
|
||||||
|
let mut potentials = vec![free_num];
|
||||||
|
let mut curr = free_num;
|
||||||
|
for _ in 0..amount {
|
||||||
|
if let Some(next) = self.1.iter().find(|v| **v == curr + 1) {
|
||||||
|
potentials.push(*next);
|
||||||
|
curr = *next;
|
||||||
|
} else {
|
||||||
|
continue 'outer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
self.1
|
||||||
|
.retain_mut(|v| potentials.iter().find(|p| v != *p).is_none());
|
||||||
|
return potentials;
|
||||||
|
}
|
||||||
let mut returned = Vec::new();
|
let mut returned = Vec::new();
|
||||||
for _ in 0..amount {
|
for _ in 0..amount {
|
||||||
returned.push(self.new());
|
returned.push(self.new());
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user