[Python-checkins] cpython: Minor code cleanups.

raymond.hettinger python-checkins at python.org
Tue May 12 04:25:46 CEST 2015


https://hg.python.org/cpython/rev/5c3813e74f88
changeset:   95963:5c3813e74f88
user:        Raymond Hettinger <python at rcn.com>
date:        Mon May 11 19:25:32 2015 -0700
summary:
  Minor code cleanups.

files:
  Modules/_heapqmodule.c |  10 +++++-----
  1 files changed, 5 insertions(+), 5 deletions(-)


diff --git a/Modules/_heapqmodule.c b/Modules/_heapqmodule.c
--- a/Modules/_heapqmodule.c
+++ b/Modules/_heapqmodule.c
@@ -138,7 +138,7 @@
 
     lastelt = PyList_GET_ITEM(heap, n-1) ;
     Py_INCREF(lastelt);
-    if (PyList_SetSlice(heap, n-1, n, NULL) < 0) {
+    if (PyList_SetSlice(heap, n-1, n, NULL)) {
         Py_DECREF(lastelt);
         return NULL;
     }
@@ -177,7 +177,7 @@
         return NULL;
     }
 
-    if (PyList_GET_SIZE(heap) < 1) {
+    if (PyList_GET_SIZE(heap) == 0) {
         PyErr_SetString(PyExc_IndexError, "index out of range");
         return NULL;
     }
@@ -222,7 +222,7 @@
         return NULL;
     }
 
-    if (PyList_GET_SIZE(heap) < 1) {
+    if (PyList_GET_SIZE(heap) == 0) {
         Py_INCREF(item);
         return item;
     }
@@ -340,8 +340,8 @@
        n is odd = 2*j+1, this is (2*j+1-1)/2 = j so j-1 is the largest,
        and that's again n//2-1.
     */
-    for (i=n/2-1 ; i>=0 ; i--)
-        if(siftup_func((PyListObject *)heap, i))
+    for (i = n/2 - 1 ; i >= 0 ; i--)
+        if (siftup_func((PyListObject *)heap, i))
             return NULL;
     Py_RETURN_NONE;
 }

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list