Skip to content

Commit

Permalink
Removes unnecessary Sized bounds in bucket map (#30990)
Browse files Browse the repository at this point in the history
  • Loading branch information
brooksprumo authored Mar 30, 2023
1 parent 89f7d4a commit 399b7ba
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions bucket_map/src/bucket_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,19 +178,19 @@ impl<O: BucketOccupied> BucketStorage<O> {
self.get_start_offset_with_header(ix) + O::offset_to_first_data()
}

pub fn get<T: Sized>(&self, ix: u64) -> &T {
pub fn get<T>(&self, ix: u64) -> &T {
let slice = self.get_cell_slice::<T>(ix, 1);
// SAFETY: `get_cell_slice` ensures there's at least one element in the slice
unsafe { slice.get_unchecked(0) }
}

pub fn get_mut<T: Sized>(&mut self, ix: u64) -> &mut T {
pub fn get_mut<T>(&mut self, ix: u64) -> &mut T {
let slice = self.get_mut_cell_slice::<T>(ix, 1);
// SAFETY: `get_mut_cell_slice` ensures there's at least one element in the slice
unsafe { slice.get_unchecked_mut(0) }
}

pub fn get_cell_slice<T: Sized>(&self, ix: u64, len: u64) -> &[T] {
pub fn get_cell_slice<T>(&self, ix: u64, len: u64) -> &[T] {
let start = self.get_start_offset_no_header(ix);
let slice = {
let size = std::mem::size_of::<T>() * len as usize;
Expand All @@ -206,7 +206,7 @@ impl<O: BucketOccupied> BucketStorage<O> {
unsafe { std::slice::from_raw_parts(ptr, len as usize) }
}

pub fn get_mut_cell_slice<T: Sized>(&mut self, ix: u64, len: u64) -> &mut [T] {
pub fn get_mut_cell_slice<T>(&mut self, ix: u64, len: u64) -> &mut [T] {
let start = self.get_start_offset_no_header(ix);
let slice = {
let size = std::mem::size_of::<T>() * len as usize;
Expand Down

0 comments on commit 399b7ba

Please sign in to comment.