Skip to content

Commit

Permalink
Switch to built-in div_ceil()
Browse files Browse the repository at this point in the history
  • Loading branch information
maximbaz committed Dec 18, 2024
1 parent f6f0312 commit c2c5242
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/brightness/controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ impl Controller {
(_, Some(current)) if desired == current => (),
(_, Some(current)) => {
let step = if desired > current {
div_ceil(desired - current, TRANSITION_MAX_MS)
(desired - current).div_ceil(TRANSITION_MAX_MS) as i64
} else {
-div_ceil(current - desired, TRANSITION_MAX_MS)
-((current - desired).div_ceil(TRANSITION_MAX_MS) as i64)
};
self.target = Some(Target { desired, step });
}
Expand Down Expand Up @@ -120,10 +120,6 @@ impl Controller {
}
}

fn div_ceil(x: u64, y: u64) -> i64 {
((x + y - 1) / y) as i64
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down

0 comments on commit c2c5242

Please sign in to comment.