From 68e4ac48961ba032dc6f4e5c6b63f5063d0fe1b4 Mon Sep 17 00:00:00 2001 From: Arthur Meyre Date: Mon, 19 Aug 2024 14:36:58 +0200 Subject: [PATCH] chore(ci): fix lints for new nightly toolchain --- apps/trivium/src/kreyvium/kreyvium.rs | 21 +++++++-------------- apps/trivium/src/kreyvium/kreyvium_byte.rs | 14 ++++---------- apps/trivium/src/trivium/trivium_bool.rs | 21 +++++++-------------- apps/trivium/src/trivium/trivium_byte.rs | 14 ++++---------- tfhe/benches/shortint/oprf.rs | 2 +- 5 files changed, 23 insertions(+), 49 deletions(-) diff --git a/apps/trivium/src/kreyvium/kreyvium.rs b/apps/trivium/src/kreyvium/kreyvium.rs index 695607cff..9ada5bfe5 100644 --- a/apps/trivium/src/kreyvium/kreyvium.rs +++ b/apps/trivium/src/kreyvium/kreyvium.rs @@ -148,10 +148,9 @@ where /// Computes one turn of the stream, updating registers and outputting the new bit. pub fn next_bool(&mut self) -> T { - match &self.fhe_key { - Some(sk) => set_server_key(sk.clone()), - None => (), - }; + if let Some(sk) = &self.fhe_key { + set_server_key(sk.clone()); + } let [o, a, b, c] = self.get_output_and_values(0); @@ -226,18 +225,12 @@ where /// Computes 64 turns of the stream, outputting the 64 bits all at once in a /// Vec (first value is oldest, last is newest) pub fn next_64(&mut self) -> Vec { - match &self.fhe_key { - Some(sk) => { - rayon::broadcast(|_| set_server_key(sk.clone())); - } - None => (), + if let Some(sk) = &self.fhe_key { + rayon::broadcast(|_| set_server_key(sk.clone())); } let mut values = self.get_64_output_and_values(); - match &self.fhe_key { - Some(_) => { - rayon::broadcast(|_| unset_server_key()); - } - None => (), + if self.fhe_key.is_some() { + rayon::broadcast(|_| unset_server_key()); } let mut ret = Vec::::with_capacity(64); diff --git a/apps/trivium/src/kreyvium/kreyvium_byte.rs b/apps/trivium/src/kreyvium/kreyvium_byte.rs index d2a345014..0ebc0ce60 100644 --- a/apps/trivium/src/kreyvium/kreyvium_byte.rs +++ b/apps/trivium/src/kreyvium/kreyvium_byte.rs @@ -237,18 +237,12 @@ where /// Computes 64 turns of the stream, outputting the 64 bits (in 8 bytes) all at once in a /// Vec (first value is oldest, last is newest) pub fn next_64(&mut self) -> Vec { - match &self.fhe_key { - Some(sk) => { - rayon::broadcast(|_| set_server_key(sk.clone())); - } - None => (), + if let Some(sk) = &self.fhe_key { + rayon::broadcast(|_| set_server_key(sk.clone())); } let values = self.get_64_output_and_values(); - match &self.fhe_key { - Some(_) => { - rayon::broadcast(|_| unset_server_key()); - } - None => (), + if self.fhe_key.is_some() { + rayon::broadcast(|_| unset_server_key()); } let mut bytes = Vec::::with_capacity(8); diff --git a/apps/trivium/src/trivium/trivium_bool.rs b/apps/trivium/src/trivium/trivium_bool.rs index 4e46927c3..b4243c211 100644 --- a/apps/trivium/src/trivium/trivium_bool.rs +++ b/apps/trivium/src/trivium/trivium_bool.rs @@ -120,10 +120,9 @@ where /// Computes one turn of the stream, updating registers and outputting the new bit. pub fn next_bool(&mut self) -> T { - match &self.fhe_key { - Some(sk) => set_server_key(sk.clone()), - None => (), - }; + if let Some(sk) = &self.fhe_key { + set_server_key(sk.clone()); + } let [o, a, b, c] = self.get_output_and_values(0); @@ -196,18 +195,12 @@ where /// Computes 64 turns of the stream, outputting the 64 bits all at once in a /// Vec (first value is oldest, last is newest) pub fn next_64(&mut self) -> Vec { - match &self.fhe_key { - Some(sk) => { - rayon::broadcast(|_| set_server_key(sk.clone())); - } - None => (), + if let Some(sk) = &self.fhe_key { + rayon::broadcast(|_| set_server_key(sk.clone())); } let mut values = self.get_64_output_and_values(); - match &self.fhe_key { - Some(_) => { - rayon::broadcast(|_| unset_server_key()); - } - None => (), + if self.fhe_key.is_some() { + rayon::broadcast(|_| unset_server_key()); } let mut ret = Vec::::with_capacity(64); diff --git a/apps/trivium/src/trivium/trivium_byte.rs b/apps/trivium/src/trivium/trivium_byte.rs index edb417ef9..3059e866d 100644 --- a/apps/trivium/src/trivium/trivium_byte.rs +++ b/apps/trivium/src/trivium/trivium_byte.rs @@ -187,18 +187,12 @@ where /// Computes 64 turns of the stream, outputting the 64 bits (in 8 bytes) all at once in a /// Vec (first value is oldest, last is newest) pub fn next_64(&mut self) -> Vec { - match &self.fhe_key { - Some(sk) => { - rayon::broadcast(|_| set_server_key(sk.clone())); - } - None => (), + if let Some(sk) = &self.fhe_key { + rayon::broadcast(|_| set_server_key(sk.clone())); } let values = self.get_64_output_and_values(); - match &self.fhe_key { - Some(_) => { - rayon::broadcast(|_| unset_server_key()); - } - None => (), + if self.fhe_key.is_some() { + rayon::broadcast(|_| unset_server_key()); } let mut bytes = Vec::::with_capacity(8); diff --git a/tfhe/benches/shortint/oprf.rs b/tfhe/benches/shortint/oprf.rs index e08d29e6d..f40bb262b 100644 --- a/tfhe/benches/shortint/oprf.rs +++ b/tfhe/benches/shortint/oprf.rs @@ -14,7 +14,7 @@ fn oprf(c: &mut Criterion) { let keys = KEY_CACHE.get_from_param(param); let sks = keys.server_key(); - bench_group.bench_function(&format!("2-bits-oprf::{}", param.name()), |b| { + bench_group.bench_function(format!("2-bits-oprf::{}", param.name()), |b| { b.iter(|| { _ = black_box(sks.generate_oblivious_pseudo_random(Seed(0), 2)); })