Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
rename to size_after_pop
  • Loading branch information
eendebakpt committed Dec 26, 2022
commit 7c6c9fa0f441e65aad6037fc7705514ffaec0940
14 changes: 7 additions & 7 deletions Objects/listobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -1025,23 +1025,23 @@ list_pop_impl(PyListObject *self, Py_ssize_t index)

PyObject **items = self->ob_item;
v = items[index];
Py_ssize_t pop_after_size = Py_SIZE(self) - 1;
if(pop_after_size == 0) {
Py_ssize_t size_after_pop = Py_SIZE(self) - 1;
if(size_after_pop == 0) {
Comment thread
corona10 marked this conversation as resolved.
Outdated
Py_INCREF(v);
status = _list_clear(self);
}
else {
if ((pop_after_size - index) > 0) {
memmove(&items[index], &items[index+1], (pop_after_size - index) * sizeof(PyObject *));
if ((size_after_pop - index) > 0) {
memmove(&items[index], &items[index+1], (size_after_pop - index) * sizeof(PyObject *));
}
status = list_resize(self, Py_SIZE(self) - 1);
status = list_resize(self, size_after_pop);
}
if (status >= 0) {
return v; // and v now owns the reference the list had
return v; // and v now owns the reference the list had
}
else {
// list resize failed, need to restore
memmove(&items[index+1], &items[index], (pop_after_size - index)* sizeof(PyObject *));
memmove(&items[index+1], &items[index], (size_after_pop - index)* sizeof(PyObject *));
items[index] = v;
return NULL;
}
Expand Down