From dc0b0def3667a7ecd8cc6747eb213aaf84329ab6 Mon Sep 17 00:00:00 2001 From: Andreas Jonson Date: Sun, 5 Apr 2020 14:54:08 +0200 Subject: [PATCH] micro optimize repeat function --- src/raw/generic.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/raw/generic.rs b/src/raw/generic.rs index dc5bdc190b..6f71900cee 100644 --- a/src/raw/generic.rs +++ b/src/raw/generic.rs @@ -27,11 +27,7 @@ pub const BITMASK_MASK: BitMaskWord = 0x8080_8080_8080_8080_u64 as GroupWord; /// Helper function to replicate a byte across a `GroupWord`. #[inline] fn repeat(byte: u8) -> GroupWord { - let repeat = GroupWord::from(byte); - let repeat = repeat | repeat.wrapping_shl(8); - let repeat = repeat | repeat.wrapping_shl(16); - // This last line is a no-op with a 32-bit GroupWord - repeat | repeat.wrapping_shl(32) + GroupWord::from_ne_bytes([byte; Group::WIDTH]) } /// Abstraction over a group of control bytes which can be scanned in