From efecead7574ec8e03817da7df8fafd96aeb0e308 Mon Sep 17 00:00:00 2001 From: Nathan Essex Date: Tue, 30 Jan 2024 12:40:16 +0900 Subject: [PATCH] Remove unused features of Count --- src/counts.rs | 69 +++-------------------------------------- src/utils/sort_utils.rs | 2 +- 2 files changed, 5 insertions(+), 66 deletions(-) diff --git a/src/counts.rs b/src/counts.rs index ba08747..dcc626c 100644 --- a/src/counts.rs +++ b/src/counts.rs @@ -192,7 +192,7 @@ impl Counter { return; } else if bucket.len() == 1 { let b = bucket[0].get_level(level) as usize; - counts.inc(b); + counts[b] += 1; meta.first = b as u8; meta.last = b as u8; @@ -210,7 +210,7 @@ impl Counter { // First, count directly into the output buffer until we find a value that is out of order. for (i, item) in bucket.iter().enumerate() { let b = item.get_level(level) as usize; - counts.inc(b); + counts[b] += 1; if b < prev { continue_from = i + 1; @@ -245,12 +245,12 @@ impl Counter { rem.iter().for_each(|v| { let b = v.get_level(level) as usize; - counts.inc(b); + counts[b] += 1; }); for i in 0..256 { let agg = self.0[i * 4] + self.0[1 + i * 4] + self.0[2 + i * 4] + self.0[3 + i * 4]; - counts.add(i, agg); + counts[i] += agg; } meta.first = first; @@ -259,45 +259,12 @@ impl Counter { } } -pub struct CountIter<'a>(&'a Counts, usize); - -pub struct CountIterEnumerable<'a>(&'a mut CountIter<'a>); - -impl<'a> CountIter<'a> { - #[inline(always)] - pub fn enumerate(&'a mut self) -> CountIterEnumerable<'a> { - CountIterEnumerable(self) - } -} - impl Counts { #[inline(always)] pub fn clear(&mut self) { self.0.iter_mut().for_each(|x| *x = 0); } - #[inline(always)] - pub fn get_count(self, radix: usize) -> usize { - debug_assert!(radix < 256); - unsafe { *self.0.get_unchecked(radix) } - } - - #[inline(always)] - pub fn inc(&mut self, radix: usize) { - debug_assert!(radix < 256); - unsafe { - *self.0.get_unchecked_mut(radix) += 1; - } - } - - #[inline(always)] - pub fn add(&mut self, radix: usize, count: usize) { - debug_assert!(radix < 256); - unsafe { - *self.0.get_unchecked_mut(radix) += count; - } - } - #[inline(always)] pub fn new() -> Self { Self::default() @@ -309,34 +276,6 @@ impl Counts { } } -impl Iterator for CountIter<'_> { - type Item = usize; - - #[inline(always)] - fn next(&mut self) -> Option { - if self.1 == 256 { - return None; - } - - let out = self.0[self.1]; - self.1 += 1; - - Some(out) - } - - #[inline(always)] - fn size_hint(&self) -> (usize, Option) { - (256 - self.1, Some(256 - self.1)) - } -} - -impl ExactSizeIterator for CountIter<'_> { - #[inline(always)] - fn len(&self) -> usize { - 256 - self.1 - } -} - impl IntoIterator for Counts { type Item = usize; type IntoIter = core::array::IntoIter; diff --git a/src/utils/sort_utils.rs b/src/utils/sort_utils.rs index 6eca8d2..d6b6795 100644 --- a/src/utils/sort_utils.rs +++ b/src/utils/sort_utils.rs @@ -72,7 +72,7 @@ pub fn aggregate_tile_counts(cm: &CountManager, tile_counts: &[Counts]) -> Rc