Skip to content

Commit 95f32f1

Browse files
committed
arena: improve common patterns
1 parent ca0806c commit 95f32f1

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

src/libarena/lib.rs

+2-7
Original file line numberDiff line numberDiff line change
@@ -310,13 +310,8 @@ impl Default for DroplessArena {
310310
impl DroplessArena {
311311
pub fn in_arena<T: ?Sized>(&self, ptr: *const T) -> bool {
312312
let ptr = ptr as *const u8 as *mut u8;
313-
for chunk in &*self.chunks.borrow() {
314-
if chunk.start() <= ptr && ptr < chunk.end() {
315-
return true;
316-
}
317-
}
318313

319-
false
314+
self.chunks.borrow().iter().any(|chunk| chunk.start() <= ptr && ptr < chunk.end())
320315
}
321316

322317
fn align(&self, align: usize) {
@@ -408,7 +403,7 @@ impl DroplessArena {
408403
{
409404
assert!(!mem::needs_drop::<T>());
410405
assert!(mem::size_of::<T>() != 0);
411-
assert!(slice.len() != 0);
406+
assert!(!slice.is_empty());
412407

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

0 commit comments

Comments
 (0)