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
Apply suggestions from code review
Co-authored-by: Dong-hee Na <donghee.na92@gmail.com>
  • Loading branch information
eendebakpt and corona10 authored Dec 26, 2022
commit 44a4efe94f07040f73b0d3d0a84942001c8d5733
9 changes: 5 additions & 4 deletions Objects/listobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -1025,13 +1025,14 @@ list_pop_impl(PyListObject *self, Py_ssize_t index)

PyObject **items = self->ob_item;
v = items[index];
if(Py_SIZE(self)-1==0) {
Py_ssize_t pop_after_size = Py_SIZE(self) - 1;
if(pop_after_size == 0) {
Py_INCREF(v);
status = _list_clear(self);
}
else {
if (Py_SIZE(self)-1-index) {
memmove(&items[index], &items[index+1], (Py_SIZE(self)-1-index)* sizeof(PyObject *));
if ((pop_after_size - index) > 0) {
memmove(&items[index], &items[index+1], (pop_after_size - index) * sizeof(PyObject *));
}
status = list_resize(self, Py_SIZE(self) - 1);
}
Expand All @@ -1040,7 +1041,7 @@ list_pop_impl(PyListObject *self, Py_ssize_t index)
}
else {
// list resize failed, need to restore
memmove(&items[index+1], &items[index], (Py_SIZE(self)-1-index)* sizeof(PyObject *));
memmove(&items[index+1], &items[index], (pop_after_size - index)* sizeof(PyObject *));
items[index] = v;
return NULL;
}
Expand Down