]> granicus.if.org Git - python/commitdiff
* Eliminate duplicate call to PyObject_Size().
authorRaymond Hettinger <python@rcn.com>
Fri, 12 Mar 2004 15:30:38 +0000 (15:30 +0000)
committerRaymond Hettinger <python@rcn.com>
Fri, 12 Mar 2004 15:30:38 +0000 (15:30 +0000)
  (Spotted by Michael Hudson.)

* Now that "selflen" is no longer inside a loop, it should not be a
  register variable.

Objects/listobject.c

index 78def29bd1b99153d7cabda28b30a48bbc1c8a04..9ee5756c3b1de8f19629275b5dd3d5d6c3365266 100644 (file)
@@ -650,12 +650,13 @@ listappend(PyListObject *self, PyObject *v)
 static int
 listextend_internal(PyListObject *self, PyObject *b)
 {
-       register int selflen = PyList_GET_SIZE(self);
+       int selflen = PyList_GET_SIZE(self);
        int blen;
        register int i;
        PyObject **src, **dest;
 
-       if (PyObject_Size(b) == 0) {
+       blen = PyObject_Size(b);
+       if (blen == 0) {
                /* short circuit when b is empty */
                Py_DECREF(b);
                return 0;
@@ -679,7 +680,6 @@ listextend_internal(PyListObject *self, PyObject *b)
                }
        }
 
-       blen = PyObject_Size(b);
        if (list_resize(self, selflen + blen) == -1) {
                Py_DECREF(b);
                return -1;