Trim out some obselete implementations
This commit is contained in:
parent
ee3bdc43cf
commit
8210b6ac40
|
@ -72,13 +72,6 @@ fn test(hex_bytes: &[u8], bytes: &[u8]) {
|
||||||
.map(Box::as_ref),
|
.map(Box::as_ref),
|
||||||
stringify!(hex_bytes_dyn_unsafe_iter)
|
stringify!(hex_bytes_dyn_unsafe_iter)
|
||||||
);
|
);
|
||||||
assert_eq!(
|
|
||||||
Some(bytes),
|
|
||||||
hex_bytes_dyn_unsafe_iter_niched(hex_bytes)
|
|
||||||
.as_ref()
|
|
||||||
.map(Box::as_ref),
|
|
||||||
stringify!(hex_bytes_dyn_unsafe_iter_niched)
|
|
||||||
);
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
Some(bytes),
|
Some(bytes),
|
||||||
hex_bytes_dyn_unsafe(hex_bytes).as_ref().map(Box::as_ref),
|
hex_bytes_dyn_unsafe(hex_bytes).as_ref().map(Box::as_ref),
|
||||||
|
@ -109,7 +102,6 @@ fn benchmark_sized<const N: usize, const HEAP_ONLY: bool>(
|
||||||
|
|
||||||
const BENCH_UNSAFE: bool = true;
|
const BENCH_UNSAFE: bool = true;
|
||||||
const BENCH_UNSAFE_ITER: bool = true;
|
const BENCH_UNSAFE_ITER: bool = true;
|
||||||
const BENCH_UNSAFE_ITER_NICHED: bool = true;
|
|
||||||
const BENCH_NON_NICHED: bool = true;
|
const BENCH_NON_NICHED: bool = true;
|
||||||
|
|
||||||
fn benchmark(name: &str, bytes: &[u8], c: &mut Criterion) {
|
fn benchmark(name: &str, bytes: &[u8], c: &mut Criterion) {
|
||||||
|
@ -124,11 +116,6 @@ fn benchmark(name: &str, bytes: &[u8], c: &mut Criterion) {
|
||||||
b.iter(|| hex_bytes_dyn_unsafe_iter(black_box(bytes)))
|
b.iter(|| hex_bytes_dyn_unsafe_iter(black_box(bytes)))
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if BENCH_UNSAFE_ITER_NICHED {
|
|
||||||
c.bench_function(name!(name, "dyn unsafe iter niched"), |b| {
|
|
||||||
b.iter(|| hex_bytes_dyn_unsafe_iter_niched(black_box(bytes)))
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if BENCH_NON_NICHED {
|
if BENCH_NON_NICHED {
|
||||||
c.bench_function(name!(name, "dyn non-niched"), |b| {
|
c.bench_function(name!(name, "dyn non-niched"), |b| {
|
||||||
b.iter(|| hex_bytes_dyn(black_box(bytes)))
|
b.iter(|| hex_bytes_dyn(black_box(bytes)))
|
||||||
|
|
25
src/lib.rs
25
src/lib.rs
|
@ -735,26 +735,6 @@ pub fn hex_bytes_dyn_unsafe(ascii: &[u8]) -> Option<Box<[u8]>> {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn hex_bytes_dyn_unsafe_iter(ascii: &[u8]) -> Option<Box<[u8]>> {
|
pub fn hex_bytes_dyn_unsafe_iter(ascii: &[u8]) -> Option<Box<[u8]>> {
|
||||||
let len = ascii.len() >> 1;
|
|
||||||
if len << 1 != ascii.len() {
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
let mut bytes = Box::new_uninit_slice(len);
|
|
||||||
for (i, [msb, lsb]) in ascii
|
|
||||||
.array_chunks::<2>()
|
|
||||||
.enumerate()
|
|
||||||
{
|
|
||||||
if let Some(b) = hex_byte(*msb, *lsb) {
|
|
||||||
unsafe { *bytes.get_unchecked_mut(i) = MaybeUninit::new(b) };
|
|
||||||
} else {
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Some(unsafe { Box::<[_]>::assume_init(bytes) })
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub fn hex_bytes_dyn_unsafe_iter_niched(ascii: &[u8]) -> Option<Box<[u8]>> {
|
|
||||||
let len = ascii.len() >> 1;
|
let len = ascii.len() >> 1;
|
||||||
if len << 1 != ascii.len() {
|
if len << 1 != ascii.len() {
|
||||||
return None;
|
return None;
|
||||||
|
@ -993,9 +973,4 @@ mod test {
|
||||||
fn test_dyn_unsafe_iter() {
|
fn test_dyn_unsafe_iter() {
|
||||||
test_f!(boxed hex_bytes_dyn_unsafe_iter);
|
test_f!(boxed hex_bytes_dyn_unsafe_iter);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_dyn_unsafe_iter_niched() {
|
|
||||||
test_f!(boxed hex_bytes_dyn_unsafe_iter_niched);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue