@@ -138,7 +138,7 @@ heappop_internal(PyObject *heap, int siftup_func(PyListObject *, Py_ssize_t))
138138
139139 lastelt = PyList_GET_ITEM (heap , n - 1 ) ;
140140 Py_INCREF (lastelt );
141- if (PyList_SetSlice (heap , n - 1 , n , NULL ) < 0 ) {
141+ if (PyList_SetSlice (heap , n - 1 , n , NULL )) {
142142 Py_DECREF (lastelt );
143143 return NULL ;
144144 }
@@ -177,7 +177,7 @@ heapreplace_internal(PyObject *args, int siftup_func(PyListObject *, Py_ssize_t)
177177 return NULL ;
178178 }
179179
180- if (PyList_GET_SIZE (heap ) < 1 ) {
180+ if (PyList_GET_SIZE (heap ) == 0 ) {
181181 PyErr_SetString (PyExc_IndexError , "index out of range" );
182182 return NULL ;
183183 }
@@ -222,7 +222,7 @@ heappushpop(PyObject *self, PyObject *args)
222222 return NULL ;
223223 }
224224
225- if (PyList_GET_SIZE (heap ) < 1 ) {
225+ if (PyList_GET_SIZE (heap ) == 0 ) {
226226 Py_INCREF (item );
227227 return item ;
228228 }
@@ -340,8 +340,8 @@ heapify_internal(PyObject *heap, int siftup_func(PyListObject *, Py_ssize_t))
340340 n is odd = 2*j+1, this is (2*j+1-1)/2 = j so j-1 is the largest,
341341 and that's again n//2-1.
342342 */
343- for (i = n /2 - 1 ; i >= 0 ; i -- )
344- if (siftup_func ((PyListObject * )heap , i ))
343+ for (i = n /2 - 1 ; i >= 0 ; i -- )
344+ if (siftup_func ((PyListObject * )heap , i ))
345345 return NULL ;
346346 Py_RETURN_NONE ;
347347}
0 commit comments