diff options
author | Raymond Hettinger <python@rcn.com> | 2015-05-12 02:25:32 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2015-05-12 02:25:32 (GMT) |
commit | 99bf9a256754319a64b84dd633d91d8eedd497a7 (patch) | |
tree | 57d6ccfdd2bf91a1ad6de44e3bca7f6c104682dd /Modules | |
parent | 21ee10bf046449b4d614a5771c02f1d46845a6cb (diff) | |
download | cpython-99bf9a256754319a64b84dd633d91d8eedd497a7.zip cpython-99bf9a256754319a64b84dd633d91d8eedd497a7.tar.gz cpython-99bf9a256754319a64b84dd633d91d8eedd497a7.tar.bz2 |
Minor code cleanups.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_heapqmodule.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/Modules/_heapqmodule.c b/Modules/_heapqmodule.c index 1ed6c2b..5e724a1 100644 --- a/Modules/_heapqmodule.c +++ b/Modules/_heapqmodule.c @@ -138,7 +138,7 @@ heappop_internal(PyObject *heap, int siftup_func(PyListObject *, Py_ssize_t)) 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 @@ heapreplace_internal(PyObject *args, int siftup_func(PyListObject *, Py_ssize_t) 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 @@ heappushpop(PyObject *self, PyObject *args) return NULL; } - if (PyList_GET_SIZE(heap) < 1) { + if (PyList_GET_SIZE(heap) == 0) { Py_INCREF(item); return item; } @@ -340,8 +340,8 @@ heapify_internal(PyObject *heap, int siftup_func(PyListObject *, Py_ssize_t)) 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; } |