From 8210b6ac40f5b619d29ef4a5fb89b527cb18e838 Mon Sep 17 00:00:00 2001 From: Michael Pfaff Date: Mon, 31 Oct 2022 22:46:02 -0400 Subject: [PATCH] Trim out some obselete implementations --- benches/bench.rs | 13 ------------- src/lib.rs | 25 ------------------------- 2 files changed, 38 deletions(-) diff --git a/benches/bench.rs b/benches/bench.rs index 326fd93..ec5f81a 100644 --- a/benches/bench.rs +++ b/benches/bench.rs @@ -72,13 +72,6 @@ fn test(hex_bytes: &[u8], bytes: &[u8]) { .map(Box::as_ref), 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!( Some(bytes), hex_bytes_dyn_unsafe(hex_bytes).as_ref().map(Box::as_ref), @@ -109,7 +102,6 @@ fn benchmark_sized( const BENCH_UNSAFE: bool = true; const BENCH_UNSAFE_ITER: bool = true; -const BENCH_UNSAFE_ITER_NICHED: bool = true; const BENCH_NON_NICHED: bool = true; 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))) }); } - 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 { c.bench_function(name!(name, "dyn non-niched"), |b| { b.iter(|| hex_bytes_dyn(black_box(bytes))) diff --git a/src/lib.rs b/src/lib.rs index 5cb1a29..8f35aa3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -735,26 +735,6 @@ pub fn hex_bytes_dyn_unsafe(ascii: &[u8]) -> Option> { #[inline] pub fn hex_bytes_dyn_unsafe_iter(ascii: &[u8]) -> Option> { - 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> { let len = ascii.len() >> 1; if len << 1 != ascii.len() { return None; @@ -993,9 +973,4 @@ mod test { fn test_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); - } }