1
Fork 0
mirror of https://github.com/RGBCube/superfreq synced 2025-07-27 08:57:46 +00:00

monitor: optimize path search for CPU frequency directory

This commit is contained in:
NotAShelf 2025-05-16 03:46:54 +03:00
parent e6b7f3eb34
commit 6c2fc6652f
No known key found for this signature in database
GPG key ID: 29D95B64378DB4BF

View file

@ -399,11 +399,13 @@ pub fn get_cpu_global_info(cpu_cores: &[CpuCoreInfo]) -> CpuGlobalInfo {
eprintln!("Warning: {e}"); eprintln!("Warning: {e}");
0 0
}); });
let path = (0..core_count)
.map(|i| PathBuf::from(format!("/sys/devices/system/cpu/cpu{i}/cpufreq/"))) for i in 0..core_count {
.find(|path| path.exists()); let test_path = PathBuf::from(format!("/sys/devices/system/cpu/cpu{i}/cpufreq/"));
if let Some(test_path_buf) = path { if test_path.exists() {
cpufreq_base_path_buf = test_path_buf; cpufreq_base_path_buf = test_path;
break; // Exit the loop as soon as we find a valid path
}
} }
} }