Skip to content

Commit

Permalink
inline tail-recursive operations
Browse files Browse the repository at this point in the history
  • Loading branch information
ibraheemdev committed Nov 7, 2024
1 parent 11ddee5 commit 95bf1c9
Show file tree
Hide file tree
Showing 2 changed files with 301 additions and 251 deletions.
14 changes: 8 additions & 6 deletions src/raw/alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,19 +128,21 @@ impl<T> Table<T> {
&*self
.raw
.add(mem::size_of::<TableLayout>())
.add(i * mem::size_of::<u8>())
.add(i)
.cast::<AtomicU8>()
}

// Returns the entry at the given index.
#[inline]
pub unsafe fn entry(&self, i: usize) -> &AtomicPtr<T> {
let offset = mem::size_of::<TableLayout>()
+ mem::size_of::<u8>() * self.capacity
+ i * mem::size_of::<AtomicPtr<T>>();

debug_assert!(i < self.capacity);
&*self.raw.add(offset).cast::<AtomicPtr<T>>()

&*self
.raw
.add(mem::size_of::<TableLayout>())
.add(self.capacity)
.add(i * mem::size_of::<AtomicPtr<T>>())
.cast::<AtomicPtr<T>>()
}

/// Returns the length of the table.
Expand Down
Loading

0 comments on commit 95bf1c9

Please sign in to comment.