Skip to content

Commit f7bb664

Browse files
committed
Auto merge of #150 - andjo403:repeat, r=Amanieu
micro optimize repeat function makes it easier for the compiler and the reader with less code :) for "prof" https://godbolt.org/z/5bdD2b when I tried cargo bench I got very large variance between runs was multiple test that one time had 2x improvement to the next time have a minor regression so have more trust in the llvm-mca result.
2 parents 17572d4 + dc0b0de commit f7bb664

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

src/raw/generic.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,7 @@ pub const BITMASK_MASK: BitMaskWord = 0x8080_8080_8080_8080_u64 as GroupWord;
2727
/// Helper function to replicate a byte across a `GroupWord`.
2828
#[inline]
2929
fn repeat(byte: u8) -> GroupWord {
30-
let repeat = GroupWord::from(byte);
31-
let repeat = repeat | repeat.wrapping_shl(8);
32-
let repeat = repeat | repeat.wrapping_shl(16);
33-
// This last line is a no-op with a 32-bit GroupWord
34-
repeat | repeat.wrapping_shl(32)
30+
GroupWord::from_ne_bytes([byte; Group::WIDTH])
3531
}
3632

3733
/// Abstraction over a group of control bytes which can be scanned in

0 commit comments

Comments
 (0)