Rollup merge of #67155 - kraai:move-instead-of-binding-to-reference, r=cramertj
Move `Layout`s instead of binding by reference
This commit is contained in:
commit
196ca9dc94
@ -1142,9 +1142,9 @@ pub unsafe trait Alloc {
|
||||
where Self: Sized
|
||||
{
|
||||
match Layout::array::<T>(n) {
|
||||
Ok(ref layout) if layout.size() > 0 => {
|
||||
Ok(layout) if layout.size() > 0 => {
|
||||
unsafe {
|
||||
self.alloc(layout.clone()).map(|p| p.cast())
|
||||
self.alloc(layout).map(|p| p.cast())
|
||||
}
|
||||
}
|
||||
_ => Err(AllocErr),
|
||||
@ -1192,9 +1192,9 @@ pub unsafe trait Alloc {
|
||||
where Self: Sized
|
||||
{
|
||||
match (Layout::array::<T>(n_old), Layout::array::<T>(n_new)) {
|
||||
(Ok(ref k_old), Ok(ref k_new)) if k_old.size() > 0 && k_new.size() > 0 => {
|
||||
(Ok(k_old), Ok(k_new)) if k_old.size() > 0 && k_new.size() > 0 => {
|
||||
debug_assert!(k_old.align() == k_new.align());
|
||||
self.realloc(ptr.cast(), k_old.clone(), k_new.size()).map(NonNull::cast)
|
||||
self.realloc(ptr.cast(), k_old, k_new.size()).map(NonNull::cast)
|
||||
}
|
||||
_ => {
|
||||
Err(AllocErr)
|
||||
@ -1226,8 +1226,8 @@ pub unsafe trait Alloc {
|
||||
where Self: Sized
|
||||
{
|
||||
match Layout::array::<T>(n) {
|
||||
Ok(ref k) if k.size() > 0 => {
|
||||
Ok(self.dealloc(ptr.cast(), k.clone()))
|
||||
Ok(k) if k.size() > 0 => {
|
||||
Ok(self.dealloc(ptr.cast(), k))
|
||||
}
|
||||
_ => {
|
||||
Err(AllocErr)
|
||||
|
Loading…
Reference in New Issue
Block a user