Fix ArrayList::truncate
This commit is contained in:
parent
949097874f
commit
119e0abde2
|
@ -121,7 +121,7 @@ impl ReleasePool {
|
||||||
owned: ArrayList::new(),
|
owned: ArrayList::new(),
|
||||||
borrowed: ArrayList::new(),
|
borrowed: ArrayList::new(),
|
||||||
pointers: Box::into_raw(Box::new(Vec::with_capacity(256))),
|
pointers: Box::into_raw(Box::new(Vec::with_capacity(256))),
|
||||||
obj: Vec::new(),
|
obj: Vec::with_capacity(8),
|
||||||
p: spin::Mutex::new(Box::into_raw(Box::new(Vec::with_capacity(256)))),
|
p: spin::Mutex::new(Box::into_raw(Box::new(Vec::with_capacity(256)))),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -138,7 +138,7 @@ impl ReleasePool {
|
||||||
drop(v);
|
drop(v);
|
||||||
|
|
||||||
// release PyObjects
|
// release PyObjects
|
||||||
for ptr in vec.iter() {
|
for ptr in vec.iter_mut() {
|
||||||
ffi::Py_DECREF(ptr.as_ptr());
|
ffi::Py_DECREF(ptr.as_ptr());
|
||||||
}
|
}
|
||||||
vec.set_len(0);
|
vec.set_len(0);
|
||||||
|
@ -311,7 +311,7 @@ mod array_list {
|
||||||
if self.length <= new_len {
|
if self.length <= new_len {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
while self.inner.len() > new_len / BLOCK_SIZE + 1 {
|
while self.inner.len() > (new_len + BLOCK_SIZE - 1) / BLOCK_SIZE {
|
||||||
self.inner.pop_back();
|
self.inner.pop_back();
|
||||||
}
|
}
|
||||||
self.length = new_len;
|
self.length = new_len;
|
||||||
|
|
Loading…
Reference in a new issue