From 1d5e3db348227d5658e11782b123139c1d5d5e25 Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Fri, 11 Apr 2025 10:14:37 +0200 Subject: 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. --- src/block.rs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) 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 for Block { impl BitXor 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], + ]) } } -- cgit v1.2.3