mirror of
https://github.com/RGBCube/superfreq
synced 2025-07-27 17:07:44 +00:00
monitor: optimize path search for CPU frequency directory
This commit is contained in:
parent
e6b7f3eb34
commit
6c2fc6652f
1 changed files with 7 additions and 5 deletions
|
@ -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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue