Skip to content

Commit

Permalink
Try getting rid of bounds checks
Browse files Browse the repository at this point in the history
  • Loading branch information
terrarier2111 committed Jul 24, 2023
1 parent e8994ed commit f85d5f6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -509,11 +509,11 @@ impl<T: Send, M: Send + Sync + Default, const AUTO_FREE_IDS: bool>
{
// detect the amount of capacity we need.
let thread = thread_id::get();
let capacity = (1 << thread.bucket) as usize;
let capacity = thread.bucket_size();

let mut ret = Self::with_capacity(capacity);

let ptr = *ret.buckets[thread.bucket].get_mut();
let ptr = unsafe { *ret.buckets.get_unchecked(thread.bucket).get_mut() };

// Insert the new element into the bucket
let entry = unsafe { &*ptr.add(thread.index) };
Expand Down

0 comments on commit f85d5f6

Please sign in to comment.