sys: use Iterator::min instead of a manual version

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2022-07-26 13:21:36 +02:00
parent 36903bf2fe
commit 6e247b9593

View File

@ -166,24 +166,7 @@ impl ProcessLocker {
/// Get oldest shared lock timestamp
pub fn oldest_shared_lock(locker: Arc<Mutex<Self>>) -> Option<i64> {
let mut result = None;
let data = locker.lock().unwrap();
for v in data.shared_guard_list.values() {
result = match result {
None => Some(*v),
Some(x) => {
if x < *v {
Some(x)
} else {
Some(*v)
}
}
};
}
result
locker.lock().unwrap().shared_guard_list.values().copied().min()
}
/// Try to acquire a exclusive lock