From 01a8efe4d491c5a75e4e911f01dcc0ae5c582bf0 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Thu, 26 Oct 2023 18:09:58 -0700 Subject: [PATCH] return fixed length array and len to avoid heap allocation --- src/zeroes.rs | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/zeroes.rs b/src/zeroes.rs index f681a2d..3866ec3 100644 --- a/src/zeroes.rs +++ b/src/zeroes.rs @@ -2,31 +2,31 @@ use crate::integer::Planar64; #[inline] -pub fn zeroes2(a0:Planar64,a1:Planar64,a2:Planar64) -> Vec{ +pub fn zeroes2<'a>(a0:Planar64,a1:Planar64,a2:Planar64)->&'a [Planar64]{ if a2==Planar64::ZERO{ - return zeroes1(a0, a1); + return zeroes1(a0,a1); } let radicand=a1.get() as i128*a1.get() as i128-a2.get() as i128*a0.get() as i128*4; - if 0 Vec { +pub fn zeroes1<'a>(a0:Planar64,a1:Planar64)->&'a [Planar64]{ if a1==Planar64::ZERO{ - return vec![]; - } else { - return vec![-a0/a1]; + &[] + }else{ + &[-a0/a1] } } \ No newline at end of file