Skip to content

Commit 19ccb03

Browse files
committed
Add #[inline] attributes
1 parent bb622b2 commit 19ccb03

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

block-padding/src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,15 @@ pub trait Padding {
3333
/// # Panics
3434
/// If `pos` is bigger than `BlockSize`. Most padding algorithms also
3535
/// panic if they are equal.
36+
#[inline]
3637
fn pad<BlockSize: ArraySize>(block: &mut Array<u8, BlockSize>, pos: usize) {
3738
Self::raw_pad(block.as_mut_slice(), pos);
3839
}
3940

4041
/// Unpad data in `block`.
4142
///
4243
/// Returns error if the block contains malformed padding.
44+
#[inline]
4345
fn unpad<BlockSize: ArraySize>(block: &Array<u8, BlockSize>) -> Result<&[u8], Error> {
4446
Self::raw_unpad(block.as_slice())
4547
}
@@ -51,6 +53,7 @@ pub trait Padding {
5153
/// is multiple of block size. All other padding implementations should always return
5254
/// `Ok(blocks, Some(tail_block))`.
5355
#[allow(clippy::type_complexity)]
56+
#[inline]
5457
fn pad_detached<BlockSize: ArraySize>(
5558
data: &[u8],
5659
) -> Result<(&[Array<u8, BlockSize>], Option<Array<u8, BlockSize>>), Error> {
@@ -65,6 +68,7 @@ pub trait Padding {
6568
/// Unpad data in `blocks` and return unpadded byte slice.
6669
///
6770
/// Returns error if the block contains malformed padding.
71+
#[inline]
6872
fn unpad_blocks<BlockSize: ArraySize>(blocks: &[Array<u8, BlockSize>]) -> Result<&[u8], Error> {
6973
let bs = BlockSize::USIZE;
7074
let (last_block, full_blocks) = blocks.split_last().ok_or(Error)?;
@@ -116,6 +120,7 @@ impl Padding for ZeroPadding {
116120
Ok(&block[..0])
117121
}
118122

123+
#[inline]
119124
fn unpad_blocks<BlockSize: ArraySize>(blocks: &[Array<u8, BlockSize>]) -> Result<&[u8], Error> {
120125
let buf = Array::slice_as_flattened(blocks);
121126
for i in (0..buf.len()).rev() {
@@ -348,6 +353,7 @@ impl Padding for NoPadding {
348353
Ok(block)
349354
}
350355

356+
#[inline]
351357
fn unpad_blocks<BlockSize: ArraySize>(blocks: &[Array<u8, BlockSize>]) -> Result<&[u8], Error> {
352358
Ok(Array::slice_as_flattened(blocks))
353359
}

0 commit comments

Comments
 (0)