Skip to content

Commit

Permalink
Merge branch 'main' into inline-split
Browse files Browse the repository at this point in the history
  • Loading branch information
Geal committed Apr 25, 2024
2 parents 822ec57 + 1ce0fad commit 30c7595
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 36 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/codspeed.yml
Expand Up @@ -23,12 +23,10 @@ jobs:
bins: cargo-codspeed

- name: Build the benchmark target(s)
working-directory: ./benchmarks
run: cargo codspeed build
run: cargo codspeed build -p benchmarks

- name: Run the benchmarks
uses: CodSpeedHQ/action@v2
with:
working-directory: ./benchmarks
run: cargo codspeed run
run: cargo codspeed run -p benchmarks
token: ${{ secrets.CODSPEED_TOKEN }}
62 changes: 30 additions & 32 deletions src/bits/complete.rs
Expand Up @@ -42,41 +42,39 @@ where
move |(input, bit_offset): (I, usize)| {
if count == 0 {
Ok(((input, bit_offset), 0u8.into()))
} else if input.input_len() * 8 < count + bit_offset {
Err(Err::Error(E::from_error_kind(
(input, bit_offset),
ErrorKind::Eof,
)))
} else {
if input.input_len() * 8 < count + bit_offset {
Err(Err::Error(E::from_error_kind(
(input, bit_offset),
ErrorKind::Eof,
)))
} else {
let cnt = (count + bit_offset).div(8);
let mut acc: O = 0_u8.into();
let mut offset: usize = bit_offset;
let mut remaining: usize = count;
let mut end_offset: usize = 0;

for byte in input.iter_elements().take(cnt + 1) {
if remaining == 0 {
break;
}
let val: O = if offset == 0 {
byte.into()
} else {
((byte << offset) >> offset).into()
};

if remaining < 8 - offset {
acc += val >> (8 - offset - remaining);
end_offset = remaining + offset;
break;
} else {
acc += val << (remaining - (8 - offset));
remaining -= 8 - offset;
offset = 0;
}
let cnt = (count + bit_offset).div(8);
let mut acc: O = 0_u8.into();
let mut offset: usize = bit_offset;
let mut remaining: usize = count;
let mut end_offset: usize = 0;

for byte in input.iter_elements().take(cnt + 1) {
if remaining == 0 {
break;
}
let val: O = if offset == 0 {
byte.into()
} else {
((byte << offset) >> offset).into()
};

if remaining < 8 - offset {
acc += val >> (8 - offset - remaining);
end_offset = remaining + offset;
break;
} else {
acc += val << (remaining - (8 - offset));
remaining -= 8 - offset;
offset = 0;
}
Ok(((input.take_from(cnt), end_offset), acc))
}
Ok(((input.take_from(cnt), end_offset), acc))
}
}
}
Expand Down

0 comments on commit 30c7595

Please sign in to comment.