Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6e058d7

Browse files
committed
* Eliminate duplicate call to PyObject_Size().
(Spotted by Michael Hudson.) * Now that "selflen" is no longer inside a loop, it should not be a register variable.
1 parent 2d783e9 commit 6e058d7

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

Objects/listobject.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -650,12 +650,13 @@ listappend(PyListObject *self, PyObject *v)
650650
static int
651651
listextend_internal(PyListObject *self, PyObject *b)
652652
{
653-
register int selflen = PyList_GET_SIZE(self);
653+
int selflen = PyList_GET_SIZE(self);
654654
int blen;
655655
register int i;
656656
PyObject **src, **dest;
657657

658-
if (PyObject_Size(b) == 0) {
658+
blen = PyObject_Size(b);
659+
if (blen == 0) {
659660
/* short circuit when b is empty */
660661
Py_DECREF(b);
661662
return 0;
@@ -679,7 +680,6 @@ listextend_internal(PyListObject *self, PyObject *b)
679680
}
680681
}
681682

682-
blen = PyObject_Size(b);
683683
if (list_resize(self, selflen + blen) == -1) {
684684
Py_DECREF(b);
685685
return -1;

0 commit comments

Comments
 (0)