Skip to content

Commit

Permalink
Revert "Made code worse"
Browse files Browse the repository at this point in the history
This reverts commit 604dcae.
  • Loading branch information
1Git2Clone committed Nov 17, 2024
1 parent 604dcae commit 4f93c77
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions src/utils/gcd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ where
/// NOTE: Exists for the internal LCM implementation.
#[deprecated(note = "use crate::utils::gcd::Gcd::gcd() instead.")]
#[must_use]
fn __gcd_no_zero_check(mut self, mut other: Self) -> u32 {
fn __gcd_no_zero_check(mut self, mut other: Self) -> Self {
let k = {
let i = self.trailing_zeros();
let j = other.trailing_zeros();
i.min(j)
i.min(j) as usize
};

while !other.is_zero() {
Expand All @@ -27,13 +27,13 @@ where
other >>= other.trailing_zeros();
}

(self.to_u32().unwrap()) << k
self << k
}
fn gcd(self, other: Self) -> u32 {
fn gcd(self, other: Self) -> Self {
if self.is_zero() {
return self.to_u32().unwrap();
return self;
} else if other.is_zero() {
return other.to_u32().unwrap();
return other;
}
#[allow(deprecated)]
self.__gcd_no_zero_check(other)
Expand Down
8 changes: 4 additions & 4 deletions src/utils/lcm.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
use crate::utils::gcd::Gcd;

pub trait Lcm: Gcd {
fn lcm(self, other: Self) -> u32 {
fn lcm(self, other: Self) -> Self {
if self.is_zero() {
return self.to_u32().unwrap();
return self;
} else if other.is_zero() {
return other.to_u32().unwrap();
return other;
}
#[allow(deprecated)] // Internal call to save second zero checks.
{
(self * other).to_u32().unwrap() / (self.__gcd_no_zero_check(other))
(self * other) / (self.__gcd_no_zero_check(other))
}
}
}
Expand Down

0 comments on commit 4f93c77

Please sign in to comment.