mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-15 20:45:45 +03:00
arena: improve common patterns
This commit is contained in:
+2
-7
@@ -310,13 +310,8 @@ fn default() -> 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) {
|
||||
@@ -408,7 +403,7 @@ pub fn alloc_slice<T>(&self, slice: &[T]) -> &mut [T]
|
||||
{
|
||||
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>(),
|
||||
|
||||
Reference in New Issue
Block a user