diff options
author | Daniel Schadt <kingdread@gmx.de> | 2025-06-13 17:40:05 +0200 |
---|---|---|
committer | Daniel Schadt <kingdread@gmx.de> | 2025-06-13 17:40:05 +0200 |
commit | 4bf0986d8c7a19c0b0eb7d875817fa8981c4d32e (patch) | |
tree | 78fd621f0cb6b564e538f2536861d70e102899d0 | |
parent | ffc0299cfd9bf32e02b61d15e52904d7ce268565 (diff) | |
download | zears-4bf0986d8c7a19c0b0eb7d875817fa8981c4d32e.tar.gz zears-4bf0986d8c7a19c0b0eb7d875817fa8981c4d32e.tar.bz2 zears-4bf0986d8c7a19c0b0eb7d875817fa8981c4d32e.zip |
implement Block::pad without integer conversion
Here, this gives around 2% in speedup in the 1024 byte case.
-rw-r--r-- | src/block.rs | 4 |
1 files changed, 3 insertions, 1 deletions
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. |