Simplify selection of spare replacement bucket
This commit is contained in:
parent
203b949d43
commit
6462027b7f
|
@ -564,18 +564,15 @@ impl BridgeAuth {
|
||||||
bucketnums.push(*bucketnum);
|
bucketnums.push(*bucketnum);
|
||||||
}
|
}
|
||||||
// Get the first spare and remove it from the spares set.
|
// Get the first spare and remove it from the spares set.
|
||||||
let mut spare = *self.bridge_table.spares.iter().next().unwrap();
|
let Some(spare) = self
|
||||||
// Check that the first spare in the list of spares is not the one to be replaced
|
.bridge_table
|
||||||
if bucketnums.contains(&spare) {
|
.spares
|
||||||
// If it is, take the last spare instead
|
.iter()
|
||||||
spare = *self.bridge_table.spares.iter().last().unwrap();
|
.find(|x| !bucketnums.contains(x))
|
||||||
// If this is the same bucketnum, there is only one spare bucket with the bridge
|
.cloned()
|
||||||
// to be replaced in it, so don't replace it.
|
else {
|
||||||
if bucketnums.contains(&spare) {
|
return ReplaceSuccess::NotReplaced;
|
||||||
res = ReplaceSuccess::NotReplaced;
|
};
|
||||||
return res;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
self.bridge_table.spares.remove(&spare);
|
self.bridge_table.spares.remove(&spare);
|
||||||
self.bridge_table.recycleable_keys.push(spare);
|
self.bridge_table.recycleable_keys.push(spare);
|
||||||
// Get the actual bridges from the spare bucket
|
// Get the actual bridges from the spare bucket
|
||||||
|
|
Loading…
Reference in New Issue