Skip to content

Commit

Permalink
arena: improve common patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
ljedrz committed Dec 2, 2018
1 parent ca0806c commit 95f32f1
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions src/libarena/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,13 +310,8 @@ impl Default for DroplessArena {
impl DroplessArena {
pub fn in_arena<T: ?Sized>(&self, ptr: *const T) -> bool {
let ptr = ptr as *const u8 as *mut u8;
for chunk in &*self.chunks.borrow() {
if chunk.start() <= ptr && ptr < chunk.end() {
return true;
}
}

false
self.chunks.borrow().iter().any(|chunk| chunk.start() <= ptr && ptr < chunk.end())
}

fn align(&self, align: usize) {
Expand Down Expand Up @@ -408,7 +403,7 @@ impl DroplessArena {
{
assert!(!mem::needs_drop::<T>());
assert!(mem::size_of::<T>() != 0);
assert!(slice.len() != 0);
assert!(!slice.is_empty());

let mem = self.alloc_raw(
slice.len() * mem::size_of::<T>(),
Expand Down

0 comments on commit 95f32f1

Please sign in to comment.