diff options
author | Daniel Schadt <kingdread@gmx.de> | 2025-04-11 10:14:37 +0200 |
---|---|---|
committer | Daniel Schadt <kingdread@gmx.de> | 2025-04-11 10:14:37 +0200 |
commit | 1d5e3db348227d5658e11782b123139c1d5d5e25 (patch) | |
tree | 8643a52ce71afb1d3397e64cb6230e786e7d0f61 /src/block.rs | |
parent | 170d9413b4d5d4b2c43f53343be4e43350e3e83f (diff) | |
download | zears-1d5e3db348227d5658e11782b123139c1d5d5e25.tar.gz zears-1d5e3db348227d5658e11782b123139c1d5d5e25.tar.bz2 zears-1d5e3db348227d5658e11782b123139c1d5d5e25.zip |
manually compute Block ^ Block
This gives around 30% speedup, presumably because casting to the int is
more expensive than I thought. This operation is used so frequently in
the hot loop that even a tiny speedup can add up quickly.
Diffstat (limited to 'src/block.rs')
-rw-r--r-- | src/block.rs | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/block.rs b/src/block.rs index 28ef0b3..8bf8647 100644 --- a/src/block.rs +++ b/src/block.rs @@ -81,7 +81,24 @@ impl From<u128> for Block { impl BitXor<Block> for Block { type Output = Block; fn bitxor(self, rhs: Block) -> Block { - Block::from(self.to_int() ^ rhs.to_int()) + Block([ + self.0[0] ^ rhs.0[0], + self.0[1] ^ rhs.0[1], + self.0[2] ^ rhs.0[2], + self.0[3] ^ rhs.0[3], + self.0[4] ^ rhs.0[4], + self.0[5] ^ rhs.0[5], + self.0[6] ^ rhs.0[6], + self.0[7] ^ rhs.0[7], + self.0[8] ^ rhs.0[8], + self.0[9] ^ rhs.0[9], + self.0[10] ^ rhs.0[10], + self.0[11] ^ rhs.0[11], + self.0[12] ^ rhs.0[12], + self.0[13] ^ rhs.0[13], + self.0[14] ^ rhs.0[14], + self.0[15] ^ rhs.0[15], + ]) } } |