From 4bf0986d8c7a19c0b0eb7d875817fa8981c4d32e Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Fri, 13 Jun 2025 17:40:05 +0200 Subject: implement Block::pad without integer conversion Here, this gives around 2% in speedup in the 1024 byte case. --- src/block.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/block.rs') diff --git a/src/block.rs b/src/block.rs index 0e64bbe..ce2d22c 100644 --- a/src/block.rs +++ b/src/block.rs @@ -72,7 +72,9 @@ impl Block { /// This corresponds to X10* in the paper. pub fn pad(&self, length: usize) -> Block { assert!(length <= 127); - Block::from_int(self.to_int() | (1 << (127 - length))) + let mut result = *self; + result[length / 8] |= 1 << (7 - length % 8); + result } /// Clip the block by setting all bits beyond the given length to 0. -- cgit v1.2.3