diff --git a/common/src/bitset.rs b/common/src/bitset.rs index 2d6b17462..0f1ccb730 100644 --- a/common/src/bitset.rs +++ b/common/src/bitset.rs @@ -259,11 +259,7 @@ impl BitSet { // we do not check saturated els. let higher = el / 64u32; let lower = el % 64u32; - self.len += if self.tinysets[higher as usize].insert_mut(lower) { - 1 - } else { - 0 - }; + self.len += u64::from(self.tinysets[higher as usize].insert_mut(lower)); } /// Inserts an element in the `BitSet` @@ -272,11 +268,7 @@ impl BitSet { // we do not check saturated els. let higher = el / 64u32; let lower = el % 64u32; - self.len -= if self.tinysets[higher as usize].remove_mut(lower) { - 1 - } else { - 0 - }; + self.len -= u64::from(self.tinysets[higher as usize].remove_mut(lower)); } /// Returns true iff the elements is in the `BitSet`. diff --git a/common/src/serialize.rs b/common/src/serialize.rs index fc256d46b..bc893f7d0 100644 --- a/common/src/serialize.rs +++ b/common/src/serialize.rs @@ -161,8 +161,7 @@ impl FixedSize for u8 { impl BinarySerializable for bool { fn serialize(&self, writer: &mut W) -> io::Result<()> { - let val = if *self { 1 } else { 0 }; - writer.write_u8(val) + writer.write_u8(u8::from(*self)) } fn deserialize(reader: &mut R) -> io::Result { let val = reader.read_u8()?; diff --git a/fastfield_codecs/src/monotonic_mapping.rs b/fastfield_codecs/src/monotonic_mapping.rs index 3466bb151..d4e673040 100644 --- a/fastfield_codecs/src/monotonic_mapping.rs +++ b/fastfield_codecs/src/monotonic_mapping.rs @@ -36,11 +36,7 @@ impl MonotonicallyMappableToU64 for i64 { impl MonotonicallyMappableToU64 for bool { #[inline(always)] fn to_u64(self) -> u64 { - if self { - 1 - } else { - 0 - } + u64::from(self) } #[inline(always)]