Skip to content

Commit 1c459d0

Browse files
committed
one more specialization
1 parent 272d4d1 commit 1c459d0

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

Objects/listobject.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -700,10 +700,16 @@ list_ass_slice(PyListObject *a, Py_ssize_t ilow, Py_ssize_t ihigh, PyObject *v)
700700
}
701701

702702
if (d < 0) { /* Delete -d items */
703-
Py_ssize_t tail;
704-
tail = (Py_SIZE(a) - ihigh) * sizeof(PyObject *);
705-
memmove(&item[ihigh+d], &item[ihigh], tail);
703+
if((Py_SIZE(a) - ihigh)==1) {
704+
item[ihigh-1] = item[ihigh];
705+
}
706+
else {
707+
Py_ssize_t tail;
708+
tail = (Py_SIZE(a) - ihigh) * sizeof(PyObject *);
709+
memmove(&item[ihigh+d], &item[ihigh], tail);
710+
}
706711
if (list_resize(a, Py_SIZE(a) + d) < 0) {
712+
Py_ssize_t tail = (Py_SIZE(a) - ihigh) * sizeof(PyObject *);
707713
memmove(&item[ihigh], &item[ihigh+d], tail);
708714
memcpy(&item[ilow], recycle, s);
709715
goto Error;

0 commit comments

Comments
 (0)