Skip to content
This repository has been archived by the owner on Jan 30, 2024. It is now read-only.

Simplify fn round_up #339

Merged
merged 2 commits into from
Aug 7, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
## [Unreleased]


- [#xxx] Simplify `fn round_up`
Urhengulas marked this conversation as resolved.
Show resolved Hide resolved
- [#337] Clean snapshot tests
- [#335] Add unit tests for `fn round_up`
- [#334] Simplify snapshot tests
Expand All @@ -23,6 +24,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
- [#314] Clarify documentation in README
- [#293] Update snapshot tests to new TRACE output

[#xxx]: https://github.com/knurling-rs/probe-run/pull/xxx
Urhengulas marked this conversation as resolved.
Show resolved Hide resolved
[#337]: https://github.com/knurling-rs/probe-run/pull/337
[#335]: https://github.com/knurling-rs/probe-run/pull/335
[#334]: https://github.com/knurling-rs/probe-run/pull/334
Expand Down
8 changes: 3 additions & 5 deletions src/canary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,9 @@ impl Canary {

/// Rounds up to the next multiple of `k` that is greater or equal to `n`.
fn round_up(n: u32, k: u32) -> u32 {
let rem = n % k;
if rem == 0 {
n
} else {
n + k - rem
match n % k {
0 => n,
rem => n + k - rem,
}
}

Expand Down