force inlining of very simple methods
@@ -14,8 +14,8 @@ pub trait Ring : Add<Self, Output=Self> + Sub<Self, Output=Self> + Neg<Output=Se
}
impl Ring for isize {
- fn is_zero(&self) -> bool { *self == 0 }
- fn zero() -> Self { 0 }
+ #[inline(always)] fn is_zero(&self) -> bool { *self == 0 }
+ #[inline(always)] fn zero() -> Self { 0 }
}
@@ -28,7 +28,7 @@ pub struct RingPair<R1: Ring, R2: Ring> {
impl<R1: Ring, R2: Ring> RingPair<R1, R2> {
/// Creates a new ring pair from two elements.
- pub fn new(elt1: R1, elt2: R2) -> Self {
+ #[inline(always)] pub fn new(elt1: R1, elt2: R2) -> Self {
RingPair {
element1: elt1,
element2: elt2,
@@ -37,13 +37,13 @@ impl<R1: Ring, R2: Ring> RingPair<R1, R2> {
}
impl<R1: Ring, R2: Ring> Ring for RingPair<R1, R2> {
- fn is_zero(&self) -> bool { self.element1.is_zero() && self.element2.is_zero() }
- fn zero() -> Self { RingPair { element1: R1::zero(), element2: R2::zero() } }
+ #[inline(always)] fn is_zero(&self) -> bool { self.element1.is_zero() && self.element2.is_zero() }
+ #[inline(always)] fn zero() -> Self { RingPair { element1: R1::zero(), element2: R2::zero() } }
}
impl<R1: Ring, R2: Ring> Add<RingPair<R1, R2>> for RingPair<R1, R2> {
type Output = Self;
- fn add(self, rhs: Self) -> Self {
+ #[inline(always)] fn add(self, rhs: Self) -> Self {
RingPair {
element1: self.element1 + rhs.element1,
element2: self.element2 + rhs.element2,
@@ -53,7 +53,7 @@ impl<R1: Ring, R2: Ring> Add<RingPair<R1, R2>> for RingPair<R1, R2> {
impl<R1: Ring, R2: Ring> Sub<RingPair<R1, R2>> for RingPair<R1, R2> {
type Output = RingPair<R1, R2>;
- fn sub(self, rhs: Self) -> Self {
+ #[inline(always)] fn sub(self, rhs: Self) -> Self {
RingPair {
element1: self.element1 - rhs.element1,
element2: self.element2 - rhs.element2,
@@ -63,7 +63,7 @@ impl<R1: Ring, R2: Ring> Sub<RingPair<R1, R2>> for RingPair<R1, R2> {
impl<R1: Ring, R2: Ring> Neg for RingPair<R1, R2> {
type Output = Self;
- fn neg(self) -> Self {
+ #[inline(always)] fn neg(self) -> Self {
RingPair {
element1: -self.element1,
element2: -self.element2,
@@ -73,7 +73,7 @@ impl<R1: Ring, R2: Ring> Neg for RingPair<R1, R2> {
impl<R1: Ring, R2: Ring> Mul<RingPair<R1, R2>> for RingPair<R1, R2> {
type Output = Self;
- fn mul(self, rhs: Self) -> Self {
+ #[inline(always)] fn mul(self, rhs: Self) -> Self {
RingPair {
element1: self.element1 * rhs.element1,
element2: self.element2 * rhs.element2,
