Skip to content

Commit 0f9a946

Browse files
drop dead code
1 parent 4d4c2a1 commit 0f9a946

File tree

1 file changed

+0
-200
lines changed

1 file changed

+0
-200
lines changed

src/decoding/ringbuffer.rs

Lines changed: 0 additions & 200 deletions
Original file line numberDiff line numberDiff line change
@@ -465,66 +465,6 @@ impl RingBuffer {
465465

466466
self.tail = (self.tail + len) % self.cap;
467467
}
468-
469-
#[allow(dead_code)]
470-
/// This function is functionally the same as [RingBuffer::extend_from_within_unchecked],
471-
/// but it does not contain any branching operations.
472-
///
473-
/// SAFETY:
474-
/// Needs start + len <= self.len()
475-
/// And more then len reserved space
476-
pub unsafe fn extend_from_within_unchecked_branchless(&mut self, start: usize, len: usize) {
477-
// data slices in raw parts
478-
let ((s1_ptr, s1_len), (s2_ptr, s2_len)) = self.data_slice_parts();
479-
480-
debug_assert!(len <= s1_len + s2_len, "{} > {} + {}", len, s1_len, s2_len);
481-
482-
// calc the actually wanted slices in raw parts
483-
let start_in_s1 = usize::min(s1_len, start);
484-
let end_in_s1 = usize::min(s1_len, start + len);
485-
let m1_ptr = s1_ptr.add(start_in_s1);
486-
let m1_len = end_in_s1 - start_in_s1;
487-
488-
debug_assert!(end_in_s1 <= s1_len);
489-
debug_assert!(start_in_s1 <= s1_len);
490-
491-
let start_in_s2 = start.saturating_sub(s1_len);
492-
let end_in_s2 = start_in_s2 + (len - m1_len);
493-
let m2_ptr = s2_ptr.add(start_in_s2);
494-
let m2_len = end_in_s2 - start_in_s2;
495-
496-
debug_assert!(start_in_s2 <= s2_len);
497-
debug_assert!(end_in_s2 <= s2_len);
498-
499-
debug_assert_eq!(len, m1_len + m2_len);
500-
501-
// the free slices, must hold: f1_len + f2_len >= m1_len + m2_len
502-
let ((f1_ptr, f1_len), (f2_ptr, f2_len)) = self.free_slice_parts();
503-
504-
debug_assert!(f1_len + f2_len >= m1_len + m2_len);
505-
506-
// calc how many from where bytes go where
507-
let m1_in_f1 = usize::min(m1_len, f1_len);
508-
let m1_in_f2 = m1_len - m1_in_f1;
509-
let m2_in_f1 = usize::min(f1_len - m1_in_f1, m2_len);
510-
let m2_in_f2 = m2_len - m2_in_f1;
511-
512-
debug_assert_eq!(m1_len, m1_in_f1 + m1_in_f2);
513-
debug_assert_eq!(m2_len, m2_in_f1 + m2_in_f2);
514-
debug_assert!(f1_len >= m1_in_f1 + m2_in_f1);
515-
debug_assert!(f2_len >= m1_in_f2 + m2_in_f2);
516-
debug_assert_eq!(len, m1_in_f1 + m2_in_f1 + m1_in_f2 + m2_in_f2);
517-
518-
debug_assert!(self.buf.as_ptr().add(self.cap) > f1_ptr.add(m1_in_f1 + m2_in_f1));
519-
debug_assert!(self.buf.as_ptr().add(self.cap) > f2_ptr.add(m1_in_f2 + m2_in_f2));
520-
521-
debug_assert!((m1_in_f2 > 0) ^ (m2_in_f1 > 0) || (m1_in_f2 == 0 && m2_in_f1 == 0));
522-
523-
copy_with_checks(
524-
m1_ptr, m2_ptr, f1_ptr, f2_ptr, m1_in_f1, m2_in_f1, m1_in_f2, m2_in_f2,
525-
);
526-
self.tail = (self.tail + len) % self.cap;
527-
}
528468
}
529469

530470
impl Drop for RingBuffer {
@@ -605,146 +545,6 @@ unsafe fn copy_bytes_overshooting(
605545
);
606546
}
607547

608-
#[allow(dead_code)]
609-
#[inline(always)]
610-
#[allow(clippy::too_many_arguments)]
611-
unsafe fn copy_without_checks(
612-
m1_ptr: *const u8,
613-
m2_ptr: *const u8,
614-
f1_ptr: *mut u8,
615-
f2_ptr: *mut u8,
616-
m1_in_f1: usize,
617-
m2_in_f1: usize,
618-
m1_in_f2: usize,
619-
m2_in_f2: usize,
620-
) {
621-
f1_ptr.copy_from_nonoverlapping(m1_ptr, m1_in_f1);
622-
f1_ptr
623-
.add(m1_in_f1)
624-
.copy_from_nonoverlapping(m2_ptr, m2_in_f1);
625-
626-
f2_ptr.copy_from_nonoverlapping(m1_ptr.add(m1_in_f1), m1_in_f2);
627-
f2_ptr
628-
.add(m1_in_f2)
629-
.copy_from_nonoverlapping(m2_ptr.add(m2_in_f1), m2_in_f2);
630-
}
631-
632-
#[allow(dead_code)]
633-
#[inline(always)]
634-
#[allow(clippy::too_many_arguments)]
635-
unsafe fn copy_with_checks(
636-
m1_ptr: *const u8,
637-
m2_ptr: *const u8,
638-
f1_ptr: *mut u8,
639-
f2_ptr: *mut u8,
640-
m1_in_f1: usize,
641-
m2_in_f1: usize,
642-
m1_in_f2: usize,
643-
m2_in_f2: usize,
644-
) {
645-
if m1_in_f1 != 0 {
646-
f1_ptr.copy_from_nonoverlapping(m1_ptr, m1_in_f1);
647-
}
648-
if m2_in_f1 != 0 {
649-
f1_ptr
650-
.add(m1_in_f1)
651-
.copy_from_nonoverlapping(m2_ptr, m2_in_f1);
652-
}
653-
654-
if m1_in_f2 != 0 {
655-
f2_ptr.copy_from_nonoverlapping(m1_ptr.add(m1_in_f1), m1_in_f2);
656-
}
657-
if m2_in_f2 != 0 {
658-
f2_ptr
659-
.add(m1_in_f2)
660-
.copy_from_nonoverlapping(m2_ptr.add(m2_in_f1), m2_in_f2);
661-
}
662-
}
663-
664-
#[allow(dead_code)]
665-
#[inline(always)]
666-
#[allow(clippy::too_many_arguments)]
667-
unsafe fn copy_with_nobranch_check(
668-
m1_ptr: *const u8,
669-
m2_ptr: *const u8,
670-
f1_ptr: *mut u8,
671-
f2_ptr: *mut u8,
672-
m1_in_f1: usize,
673-
m2_in_f1: usize,
674-
m1_in_f2: usize,
675-
m2_in_f2: usize,
676-
) {
677-
let case = (m1_in_f1 > 0) as usize
678-
| (((m2_in_f1 > 0) as usize) << 1)
679-
| (((m1_in_f2 > 0) as usize) << 2)
680-
| (((m2_in_f2 > 0) as usize) << 3);
681-
682-
match case {
683-
0 => {}
684-
685-
// one bit set
686-
1 => {
687-
f1_ptr.copy_from_nonoverlapping(m1_ptr, m1_in_f1);
688-
}
689-
2 => {
690-
f1_ptr.copy_from_nonoverlapping(m2_ptr, m2_in_f1);
691-
}
692-
4 => {
693-
f2_ptr.copy_from_nonoverlapping(m1_ptr, m1_in_f2);
694-
}
695-
8 => {
696-
f2_ptr.copy_from_nonoverlapping(m2_ptr, m2_in_f2);
697-
}
698-
699-
// two bit set
700-
3 => {
701-
f1_ptr.copy_from_nonoverlapping(m1_ptr, m1_in_f1);
702-
f1_ptr
703-
.add(m1_in_f1)
704-
.copy_from_nonoverlapping(m2_ptr, m2_in_f1);
705-
}
706-
5 => {
707-
f1_ptr.copy_from_nonoverlapping(m1_ptr, m1_in_f1);
708-
f2_ptr.copy_from_nonoverlapping(m1_ptr.add(m1_in_f1), m1_in_f2);
709-
}
710-
6 => core::hint::unreachable_unchecked(),
711-
7 => core::hint::unreachable_unchecked(),
712-
9 => {
713-
f1_ptr.copy_from_nonoverlapping(m1_ptr, m1_in_f1);
714-
f2_ptr.copy_from_nonoverlapping(m2_ptr, m2_in_f2);
715-
}
716-
10 => {
717-
f1_ptr.copy_from_nonoverlapping(m2_ptr, m2_in_f1);
718-
f2_ptr.copy_from_nonoverlapping(m2_ptr.add(m2_in_f1), m2_in_f2);
719-
}
720-
12 => {
721-
f2_ptr.copy_from_nonoverlapping(m1_ptr, m1_in_f2);
722-
f2_ptr
723-
.add(m1_in_f2)
724-
.copy_from_nonoverlapping(m2_ptr, m2_in_f2);
725-
}
726-
727-
// three bit set
728-
11 => {
729-
f1_ptr.copy_from_nonoverlapping(m1_ptr, m1_in_f1);
730-
f1_ptr
731-
.add(m1_in_f1)
732-
.copy_from_nonoverlapping(m2_ptr, m2_in_f1);
733-
f2_ptr.copy_from_nonoverlapping(m2_ptr.add(m2_in_f1), m2_in_f2);
734-
}
735-
13 => {
736-
f1_ptr.copy_from_nonoverlapping(m1_ptr, m1_in_f1);
737-
f2_ptr.copy_from_nonoverlapping(m1_ptr.add(m1_in_f1), m1_in_f2);
738-
f2_ptr
739-
.add(m1_in_f2)
740-
.copy_from_nonoverlapping(m2_ptr, m2_in_f2);
741-
}
742-
14 => core::hint::unreachable_unchecked(),
743-
15 => core::hint::unreachable_unchecked(),
744-
_ => core::hint::unreachable_unchecked(),
745-
}
746-
}
747-
748548
#[cfg(test)]
749549
mod tests {
750550
use super::RingBuffer;

0 commit comments

Comments
 (0)