Skip to content

Commit

Permalink
refactor: Apply clippy lints
Browse files Browse the repository at this point in the history
  • Loading branch information
shadow3aaa committed Oct 24, 2024
1 parent 3f717e9 commit 65aeb87
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 22 deletions.
7 changes: 0 additions & 7 deletions src/cpu_common/cpu_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ use crate::file_handler::FileHandler;
#[derive(Debug)]
pub struct Info {
pub policy: i32,
pub cpus: Vec<i32>,
path: PathBuf,
pub freqs: Vec<isize>,
}
Expand All @@ -36,11 +35,6 @@ impl Info {
let path = path.as_ref();
let policy = path.file_name().unwrap().to_str().unwrap()[6..].parse()?;

let cpus: Vec<i32> = fs::read_to_string(path.join("affected_cpus"))?
.split_whitespace()
.map(|c| c.parse::<i32>().unwrap())
.collect();

let mut freqs: Vec<_> = fs::read_to_string(path.join("scaling_available_frequencies"))?
.split_whitespace()
.map(|f| f.parse().unwrap())
Expand All @@ -50,7 +44,6 @@ impl Info {

Ok(Self {
policy,
cpus,
path: path.to_path_buf(),
freqs,
})
Expand Down
22 changes: 11 additions & 11 deletions src/framework/scheduler/looper/buffer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ pub struct Buffer {
pub package_info: PackageInfo,
pub frametime_state: FrameTimeState,
pub target_fps_state: TargetFpsState,
pub buffer_state: BufferState,
pub state: BufferState,
}

impl Buffer {
Expand All @@ -82,7 +82,7 @@ impl Buffer {
frametimes: VecDeque::with_capacity(1440),
additional_frametime: Duration::ZERO,
},
buffer_state: BufferState {
state: BufferState {
last_update: Instant::now(),
calculate_timer: Instant::now(),
working_state: BufferWorkingState::Unusable,
Expand All @@ -93,7 +93,7 @@ impl Buffer {

pub fn push_frametime(&mut self, d: Duration, extension: &Extension) {
self.frametime_state.additional_frametime = Duration::ZERO;
self.buffer_state.last_update = Instant::now();
self.state.last_update = Instant::now();

while self.frametime_state.frametimes.len()
>= self.target_fps_state.target_fps.unwrap_or(144) as usize * 5
Expand All @@ -107,28 +107,28 @@ impl Buffer {
}

fn try_calculate(&mut self, extension: &Extension) {
if unlikely(self.buffer_state.calculate_timer.elapsed() >= Duration::from_secs(1)) {
self.buffer_state.calculate_timer = Instant::now();
if unlikely(self.state.calculate_timer.elapsed() >= Duration::from_secs(1)) {
self.state.calculate_timer = Instant::now();
self.calculate_current_fps();
self.calculate_target_fps(extension);
}
}

pub fn try_usable(&mut self) {
if self.buffer_state.working_state == BufferWorkingState::Unusable
&& self.buffer_state.working_state_timer.elapsed() >= Duration::from_secs(1)
if self.state.working_state == BufferWorkingState::Unusable
&& self.state.working_state_timer.elapsed() >= Duration::from_secs(1)
{
self.buffer_state.working_state = BufferWorkingState::Usable;
self.state.working_state = BufferWorkingState::Usable;
}
}

pub fn unusable(&mut self) {
self.buffer_state.working_state = BufferWorkingState::Unusable;
self.buffer_state.working_state_timer = Instant::now();
self.state.working_state = BufferWorkingState::Unusable;
self.state.working_state_timer = Instant::now();
}

pub fn additional_frametime(&mut self, extension: &Extension) {
self.frametime_state.additional_frametime = self.buffer_state.last_update.elapsed();
self.frametime_state.additional_frametime = self.state.last_update.elapsed();
self.try_calculate(extension);
}
}
4 changes: 2 additions & 2 deletions src/framework/scheduler/looper/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ impl EvolutionState {
pub fn try_evolution(
&mut self,
buffer: &Buffer,
cpu_temp_watcher: &mut CpuTempWatcher,
cpu_temp_watcher: &CpuTempWatcher,
config: &mut Config,
mode: Mode,
) {
Expand Down Expand Up @@ -243,7 +243,7 @@ impl Looper {
let control = if let Some(buffer) = &self.fas_state.buffer {
self.evolution_state.try_evolution(
buffer,
&mut self.cpu_temp_watcher,
&self.cpu_temp_watcher,
&mut self.config,
self.fas_state.mode,
);
Expand Down
2 changes: 1 addition & 1 deletion src/framework/scheduler/looper/policy/evolution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ pub fn mutate_params(params: PidParams) -> PidParams {

pub fn evaluate_fitness(
buffer: &Buffer,
cpu_temp_watcher: &mut CpuTempWatcher,
cpu_temp_watcher: &CpuTempWatcher,
config: &mut Config,
mode: Mode,
) -> Option<Fitness> {
Expand Down
2 changes: 1 addition & 1 deletion src/framework/scheduler/looper/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ impl Looper {

if let Some(buffer) = self.fas_state.buffer.as_mut() {
buffer.push_frametime(frametime, &self.extension);
Some(buffer.buffer_state.working_state)
Some(buffer.state.working_state)
} else {
let Ok(pkg) = get_process_name(data.pid) else {
return None;
Expand Down

0 comments on commit 65aeb87

Please sign in to comment.