Resolve nightly-2021-10-05 clippy complaints
This commit is contained in:
@ -121,9 +121,7 @@ impl BucketStorage {
|
||||
}
|
||||
|
||||
pub fn uid(&self, ix: u64) -> Uid {
|
||||
if ix >= self.capacity() {
|
||||
panic!("bad index size");
|
||||
}
|
||||
assert!(ix < self.capacity(), "bad index size");
|
||||
let ix = (ix * self.cell_size) as usize;
|
||||
let hdr_slice: &[u8] = &self.mmap[ix..ix + std::mem::size_of::<Header>()];
|
||||
unsafe {
|
||||
@ -133,12 +131,8 @@ impl BucketStorage {
|
||||
}
|
||||
|
||||
pub fn allocate(&self, ix: u64, uid: Uid) -> Result<(), BucketStorageError> {
|
||||
if ix >= self.capacity() {
|
||||
panic!("allocate: bad index size");
|
||||
}
|
||||
if UID_UNLOCKED == uid {
|
||||
panic!("allocate: bad uid");
|
||||
}
|
||||
assert!(ix < self.capacity(), "allocate: bad index size");
|
||||
assert!(UID_UNLOCKED != uid, "allocate: bad uid");
|
||||
let mut e = Err(BucketStorageError::AlreadyAllocated);
|
||||
let ix = (ix * self.cell_size) as usize;
|
||||
//debug!("ALLOC {} {}", ix, uid);
|
||||
@ -154,12 +148,8 @@ impl BucketStorage {
|
||||
}
|
||||
|
||||
pub fn free(&self, ix: u64, uid: Uid) {
|
||||
if ix >= self.capacity() {
|
||||
panic!("free: bad index size");
|
||||
}
|
||||
if UID_UNLOCKED == uid {
|
||||
panic!("free: bad uid");
|
||||
}
|
||||
assert!(ix < self.capacity(), "bad index size");
|
||||
assert!(UID_UNLOCKED != uid, "free: bad uid");
|
||||
let ix = (ix * self.cell_size) as usize;
|
||||
//debug!("FREE {} {}", ix, uid);
|
||||
let hdr_slice: &[u8] = &self.mmap[ix..ix + std::mem::size_of::<Header>()];
|
||||
@ -177,9 +167,7 @@ impl BucketStorage {
|
||||
}
|
||||
|
||||
pub fn get<T: Sized>(&self, ix: u64) -> &T {
|
||||
if ix >= self.capacity() {
|
||||
panic!("bad index size");
|
||||
}
|
||||
assert!(ix < self.capacity(), "bad index size");
|
||||
let start = (ix * self.cell_size) as usize + std::mem::size_of::<Header>();
|
||||
let end = start + std::mem::size_of::<T>();
|
||||
let item_slice: &[u8] = &self.mmap[start..end];
|
||||
@ -199,9 +187,7 @@ impl BucketStorage {
|
||||
}
|
||||
|
||||
pub fn get_cell_slice<T: Sized>(&self, ix: u64, len: u64) -> &[T] {
|
||||
if ix >= self.capacity() {
|
||||
panic!("bad index size");
|
||||
}
|
||||
assert!(ix < self.capacity(), "bad index size");
|
||||
let ix = self.cell_size * ix;
|
||||
let start = ix as usize + std::mem::size_of::<Header>();
|
||||
let end = start + std::mem::size_of::<T>() * len as usize;
|
||||
@ -215,9 +201,7 @@ impl BucketStorage {
|
||||
|
||||
#[allow(clippy::mut_from_ref)]
|
||||
pub fn get_mut<T: Sized>(&self, ix: u64) -> &mut T {
|
||||
if ix >= self.capacity() {
|
||||
panic!("bad index size");
|
||||
}
|
||||
assert!(ix < self.capacity(), "bad index size");
|
||||
let start = (ix * self.cell_size) as usize + std::mem::size_of::<Header>();
|
||||
let end = start + std::mem::size_of::<T>();
|
||||
let item_slice: &[u8] = &self.mmap[start..end];
|
||||
@ -229,9 +213,7 @@ impl BucketStorage {
|
||||
|
||||
#[allow(clippy::mut_from_ref)]
|
||||
pub fn get_mut_cell_slice<T: Sized>(&self, ix: u64, len: u64) -> &mut [T] {
|
||||
if ix >= self.capacity() {
|
||||
panic!("bad index size");
|
||||
}
|
||||
assert!(ix < self.capacity(), "bad index size");
|
||||
let ix = self.cell_size * ix;
|
||||
let start = ix as usize + std::mem::size_of::<Header>();
|
||||
let end = start + std::mem::size_of::<T>() * len as usize;
|
||||
|
Reference in New Issue
Block a user