Commit b89af380 authored by Raymond Hettinger's avatar Raymond Hettinger

* 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.
parent affb06d2
...@@ -650,12 +650,13 @@ listappend(PyListObject *self, PyObject *v) ...@@ -650,12 +650,13 @@ listappend(PyListObject *self, PyObject *v)
static int static int
listextend_internal(PyListObject *self, PyObject *b) listextend_internal(PyListObject *self, PyObject *b)
{ {
register int selflen = PyList_GET_SIZE(self); int selflen = PyList_GET_SIZE(self);
int blen; int blen;
register int i; register int i;
PyObject **src, **dest; PyObject **src, **dest;
if (PyObject_Size(b) == 0) { blen = PyObject_Size(b);
if (blen == 0) {
/* short circuit when b is empty */ /* short circuit when b is empty */
Py_DECREF(b); Py_DECREF(b);
return 0; return 0;
...@@ -679,7 +680,6 @@ listextend_internal(PyListObject *self, PyObject *b) ...@@ -679,7 +680,6 @@ listextend_internal(PyListObject *self, PyObject *b)
} }
} }
blen = PyObject_Size(b);
if (list_resize(self, selflen + blen) == -1) { if (list_resize(self, selflen + blen) == -1) {
Py_DECREF(b); Py_DECREF(b);
return -1; return -1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment