aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Schadt <kingdread@gmx.de>2025-06-13 17:40:05 +0200
committerDaniel Schadt <kingdread@gmx.de>2025-06-13 17:40:05 +0200
commit4bf0986d8c7a19c0b0eb7d875817fa8981c4d32e (patch)
tree78fd621f0cb6b564e538f2536861d70e102899d0 /src
parentffc0299cfd9bf32e02b61d15e52904d7ce268565 (diff)
downloadzears-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.
Diffstat (limited to 'src')
-rw-r--r--src/block.rs4
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.