Remove needless range loops

This commit is contained in:
Cecylia Bocovich 2023-06-16 12:27:40 -04:00
parent 3136a8ba85
commit 67639e2f11
No known key found for this signature in database
GPG Key ID: 009DE379FD9B7B90
2 changed files with 6 additions and 5 deletions

View File

@ -29,10 +29,11 @@ impl LoxServerContext {
pub fn remove_extra_bridges(&self) -> [BridgeLine; MAX_BRIDGES_PER_BUCKET] { pub fn remove_extra_bridges(&self) -> [BridgeLine; MAX_BRIDGES_PER_BUCKET] {
let mut extra_bridges = self.extra_bridges.lock().unwrap(); let mut extra_bridges = self.extra_bridges.lock().unwrap();
let mut return_bridges = [BridgeLine::default(); MAX_BRIDGES_PER_BUCKET]; let mut return_bridges = [BridgeLine::default(); MAX_BRIDGES_PER_BUCKET];
for i in 0..MAX_BRIDGES_PER_BUCKET { for bridge in return_bridges.iter_mut() {
return_bridges[i] = extra_bridges.remove(i); if let Some(extra) = extra_bridges.pop() {
*bridge = extra
}
} }
return_bridges return_bridges
} }

View File

@ -344,8 +344,8 @@ impl BridgeAuth {
} }
while self.bridge_table.unallocated_bridges.len() >= MAX_BRIDGES_PER_BUCKET { while self.bridge_table.unallocated_bridges.len() >= MAX_BRIDGES_PER_BUCKET {
let mut bucket = [BridgeLine::default(); MAX_BRIDGES_PER_BUCKET]; let mut bucket = [BridgeLine::default(); MAX_BRIDGES_PER_BUCKET];
for i in 0..MAX_BRIDGES_PER_BUCKET { for bridge in bucket.iter_mut() {
bucket[i] = self.bridge_table.unallocated_bridges.pop().unwrap(); *bridge = self.bridge_table.unallocated_bridges.pop().unwrap();
} }
self.add_openinv_bridges(bucket, bdb); self.add_openinv_bridges(bucket, bdb);
} }