MCPcopy Create free account
hub / github.com/RustCrypto/utils / cmovne

Method cmovne

cmov/src/slice.rs:210–228  ·  view source on GitHub ↗
(&self, rhs: &Self, input: Condition, output: &mut Condition)

Source from the content-addressed store, hash-verified

208impl CmovEq for [u8] {
209 #[inline]
210 fn cmovne(&self, rhs: &Self, input: Condition, output: &mut Condition) {
211 // Short-circuit the comparison if the slices are of different lengths, and set the output
212 // condition to the input condition.
213 if self.len() != rhs.len() {
214 *output = input;
215 return;
216 }
217
218 let (self_chunks, self_remainder) = slice_as_chunks::<u8, WORD_SIZE>(self);
219 let (rhs_chunks, rhs_remainder) = slice_as_chunks::<u8, WORD_SIZE>(rhs);
220
221 for (self_chunk, rhs_chunk) in self_chunks.iter().zip(rhs_chunks.iter()) {
222 let a = Word::from_ne_bytes(*self_chunk);
223 let b = Word::from_ne_bytes(*rhs_chunk);
224 a.cmovne(&b, input, output);
225 }
226
227 cmovne_remainder(self_remainder, rhs_remainder, input, output);
228 }
229}
230
231/// Implement [`CmovEq`] using a simple loop.

Callers 1

cmovne_remainderFunction · 0.45

Calls 3

cmovne_remainderFunction · 0.85
lenMethod · 0.80
zipMethod · 0.80

Tested by

no test coverage detected