bucket_map: Renames fns to get_slice and get_slice_mut (#31442)
This commit is contained in:
parent
a27ff1c65e
commit
bac1b2a584
|
@ -457,7 +457,7 @@ impl<'b, T: Clone + Copy + 'static> Bucket<T> {
|
||||||
|
|
||||||
// write data
|
// write data
|
||||||
assert!(!current_bucket.is_free(elem_loc));
|
assert!(!current_bucket.is_free(elem_loc));
|
||||||
let slice: &mut [T] = current_bucket.get_mut_cell_slice(
|
let slice: &mut [T] = current_bucket.get_slice_mut(
|
||||||
elem_loc,
|
elem_loc,
|
||||||
data_len as u64,
|
data_len as u64,
|
||||||
IncludeHeader::NoHeader,
|
IncludeHeader::NoHeader,
|
||||||
|
@ -511,8 +511,7 @@ impl<'b, T: Clone + Copy + 'static> Bucket<T> {
|
||||||
best_bucket.occupy(ix, false).unwrap();
|
best_bucket.occupy(ix, false).unwrap();
|
||||||
if num_slots > 0 {
|
if num_slots > 0 {
|
||||||
// copy slotlist into the data bucket
|
// copy slotlist into the data bucket
|
||||||
let slice =
|
let slice = best_bucket.get_slice_mut(ix, num_slots, IncludeHeader::NoHeader);
|
||||||
best_bucket.get_mut_cell_slice(ix, num_slots, IncludeHeader::NoHeader);
|
|
||||||
slice.iter_mut().zip(data).for_each(|(dest, src)| {
|
slice.iter_mut().zip(data).for_each(|(dest, src)| {
|
||||||
*dest = *src;
|
*dest = *src;
|
||||||
});
|
});
|
||||||
|
|
|
@ -266,25 +266,25 @@ impl<O: BucketOccupied> BucketStorage<O> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn get_header<T>(&self, ix: u64) -> &T {
|
pub(crate) fn get_header<T>(&self, ix: u64) -> &T {
|
||||||
let slice = self.get_cell_slice::<T>(ix, 1, IncludeHeader::Header);
|
let slice = self.get_slice::<T>(ix, 1, IncludeHeader::Header);
|
||||||
// SAFETY: `get_cell_slice` ensures there's at least one element in the slice
|
// SAFETY: `get_cell_slice` ensures there's at least one element in the slice
|
||||||
unsafe { slice.get_unchecked(0) }
|
unsafe { slice.get_unchecked(0) }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn get_header_mut<T>(&mut self, ix: u64) -> &mut T {
|
pub(crate) fn get_header_mut<T>(&mut self, ix: u64) -> &mut T {
|
||||||
let slice = self.get_mut_cell_slice::<T>(ix, 1, IncludeHeader::Header);
|
let slice = self.get_slice_mut::<T>(ix, 1, IncludeHeader::Header);
|
||||||
// SAFETY: `get_mut_cell_slice` ensures there's at least one element in the slice
|
// SAFETY: `get_mut_cell_slice` ensures there's at least one element in the slice
|
||||||
unsafe { slice.get_unchecked_mut(0) }
|
unsafe { slice.get_unchecked_mut(0) }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn get<T>(&self, ix: u64) -> &T {
|
pub(crate) fn get<T>(&self, ix: u64) -> &T {
|
||||||
let slice = self.get_cell_slice::<T>(ix, 1, IncludeHeader::NoHeader);
|
let slice = self.get_slice::<T>(ix, 1, IncludeHeader::NoHeader);
|
||||||
// SAFETY: `get_cell_slice` ensures there's at least one element in the slice
|
// SAFETY: `get_cell_slice` ensures there's at least one element in the slice
|
||||||
unsafe { slice.get_unchecked(0) }
|
unsafe { slice.get_unchecked(0) }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn get_mut<T>(&mut self, ix: u64) -> &mut T {
|
pub(crate) fn get_mut<T>(&mut self, ix: u64) -> &mut T {
|
||||||
let slice = self.get_mut_cell_slice::<T>(ix, 1, IncludeHeader::NoHeader);
|
let slice = self.get_slice_mut::<T>(ix, 1, IncludeHeader::NoHeader);
|
||||||
// SAFETY: `get_mut_cell_slice` ensures there's at least one element in the slice
|
// SAFETY: `get_mut_cell_slice` ensures there's at least one element in the slice
|
||||||
unsafe { slice.get_unchecked_mut(0) }
|
unsafe { slice.get_unchecked_mut(0) }
|
||||||
}
|
}
|
||||||
|
@ -301,7 +301,7 @@ impl<O: BucketOccupied> BucketStorage<O> {
|
||||||
unsafe { &*item }
|
unsafe { &*item }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn get_cell_slice<T>(&self, ix: u64, len: u64, header: IncludeHeader) -> &[T] {
|
pub(crate) fn get_slice<T>(&self, ix: u64, len: u64, header: IncludeHeader) -> &[T] {
|
||||||
let start = self.get_start_offset(ix, header);
|
let start = self.get_start_offset(ix, header);
|
||||||
let slice = {
|
let slice = {
|
||||||
let size = std::mem::size_of::<T>() * len as usize;
|
let size = std::mem::size_of::<T>() * len as usize;
|
||||||
|
@ -317,7 +317,7 @@ impl<O: BucketOccupied> BucketStorage<O> {
|
||||||
unsafe { std::slice::from_raw_parts(ptr, len as usize) }
|
unsafe { std::slice::from_raw_parts(ptr, len as usize) }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn get_mut_cell_slice<T>(
|
pub(crate) fn get_slice_mut<T>(
|
||||||
&mut self,
|
&mut self,
|
||||||
ix: u64,
|
ix: u64,
|
||||||
len: u64,
|
len: u64,
|
||||||
|
|
|
@ -404,11 +404,7 @@ impl<T: Copy + 'static> IndexEntryPlaceInBucket<T> {
|
||||||
assert!(!data_bucket.is_free(loc));
|
assert!(!data_bucket.is_free(loc));
|
||||||
|
|
||||||
ref_count = MultipleSlots::ref_count(data_bucket, loc);
|
ref_count = MultipleSlots::ref_count(data_bucket, loc);
|
||||||
data_bucket.get_cell_slice::<T>(
|
data_bucket.get_slice::<T>(loc, multiple_slots.num_slots, IncludeHeader::NoHeader)
|
||||||
loc,
|
|
||||||
multiple_slots.num_slots,
|
|
||||||
IncludeHeader::NoHeader,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
panic!("trying to read data from a free entry");
|
panic!("trying to read data from a free entry");
|
||||||
|
|
Loading…
Reference in New Issue