From afe669babd89ec919fb013bd30e8da583e79c837 Mon Sep 17 00:00:00 2001 From: ljedrz Date: Wed, 21 Oct 2020 12:06:14 +0200 Subject: [PATCH] perf: make signed_integer's is_constant method faster Signed-off-by: ljedrz --- gadgets/src/signed_integer/int_impl.rs | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/gadgets/src/signed_integer/int_impl.rs b/gadgets/src/signed_integer/int_impl.rs index 074723cfee..cb90ea2099 100644 --- a/gadgets/src/signed_integer/int_impl.rs +++ b/gadgets/src/signed_integer/int_impl.rs @@ -82,18 +82,8 @@ macro_rules! int_impl { } fn is_constant(&self) -> bool { - let mut constant = true; - // If any bits of self are allocated bits, return false - for bit in &self.bits { - match *bit { - Boolean::Is(ref _bit) => constant = false, - Boolean::Not(ref _bit) => constant = false, - Boolean::Constant(_bit) => {} - } - } - - constant + self.bits.iter().all(|bit| matches!(bit, Boolean::Constant(_))) } } };