Skip to content

Commit

Permalink
fn constrain: Cleanup and make safe (#1134)
Browse files Browse the repository at this point in the history
  • Loading branch information
kkysen authored May 28, 2024
2 parents f36b93b + 3f5de53 commit adee7fd
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/cdef.rs
Original file line number Diff line number Diff line change
Expand Up @@ -539,12 +539,12 @@ extern "C" {
}

#[inline]
pub unsafe fn constrain(diff: c_int, threshold: c_int, shift: c_int) -> c_int {
pub fn constrain(diff: c_int, threshold: c_int, shift: c_int) -> c_int {
let adiff = diff.abs();
return apply_sign(
cmp::min(adiff, cmp::max(0 as c_int, threshold - (adiff >> shift))),
apply_sign(
cmp::min(adiff, cmp::max(0, threshold - (adiff >> shift))),
diff,
);
)
}

#[inline]
Expand Down

0 comments on commit adee7fd

Please sign in to comment.