Jefffrey commented on code in PR #10363:
URL: https://github.com/apache/arrow-rs/pull/10363#discussion_r3602406579
##########
arrow-buffer/src/bigint/mod.rs:
##########
@@ -337,55 +341,65 @@ impl i256 {
/// Computes the absolute value of this i256 returning `None` if `Self ==
Self::MIN`
#[inline]
- pub fn checked_abs(self) -> Option<Self> {
- (self != Self::MIN).then(|| self.wrapping_abs())
+ pub const fn checked_abs(self) -> Option<Self> {
+ if self.high != Self::MIN.high || self.low != Self::MIN.low {
+ Some(self.wrapping_abs())
+ } else {
+ None
+ }
}
/// Negates this i256
#[inline]
- pub fn wrapping_neg(self) -> Self {
+ pub const fn wrapping_neg(self) -> Self {
Self::from_parts(!self.low, !self.high).wrapping_add(i256::ONE)
}
/// Negates this i256 returning `None` if `Self == Self::MIN`
#[inline]
- pub fn checked_neg(self) -> Option<Self> {
- (self != Self::MIN).then(|| self.wrapping_neg())
+ pub const fn checked_neg(self) -> Option<Self> {
+ if !self.is_eq(Self::MIN) {
Review Comment:
here we use `is_eq` to check against min, but above (in `checked_abs`) we
check the high/low components individually 🤔
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]