diff options
author | Raymond Hettinger <python@rcn.com> | 2015-12-08 04:45:16 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2015-12-08 04:45:16 (GMT) |
commit | 2300bf29e69ec9ecee563134f8cdfdab93b2a7c0 (patch) | |
tree | d3957f32e3f7f8d2ebf6de9b69b15f7476beaed6 /Modules | |
parent | e7ceef66ddf7a0ee4341087992d262fc5edf5cfb (diff) | |
download | cpython-2300bf29e69ec9ecee563134f8cdfdab93b2a7c0.zip cpython-2300bf29e69ec9ecee563134f8cdfdab93b2a7c0.tar.gz cpython-2300bf29e69ec9ecee563134f8cdfdab93b2a7c0.tar.bz2 |
Only update the arr variable when PyObject_RichCompareBool() has been called.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_heapqmodule.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Modules/_heapqmodule.c b/Modules/_heapqmodule.c index 28604af..1c37c75 100644 --- a/Modules/_heapqmodule.c +++ b/Modules/_heapqmodule.c @@ -78,6 +78,7 @@ siftup(PyListObject *heap, Py_ssize_t pos) if (cmp < 0) return -1; childpos += ((unsigned)cmp ^ 1); /* increment when cmp==0 */ + arr = _PyList_ITEMS(heap); /* arr may have changed */ if (endpos != PyList_GET_SIZE(heap)) { PyErr_SetString(PyExc_RuntimeError, "list changed size during iteration"); @@ -85,7 +86,6 @@ siftup(PyListObject *heap, Py_ssize_t pos) } } /* Move the smaller child up. */ - arr = _PyList_ITEMS(heap); tmp1 = arr[childpos]; tmp2 = arr[pos]; arr[childpos] = tmp2; @@ -432,6 +432,7 @@ siftup_max(PyListObject *heap, Py_ssize_t pos) if (cmp < 0) return -1; childpos += ((unsigned)cmp ^ 1); /* increment when cmp==0 */ + arr = _PyList_ITEMS(heap); /* arr may have changed */ if (endpos != PyList_GET_SIZE(heap)) { PyErr_SetString(PyExc_RuntimeError, "list changed size during iteration"); @@ -439,7 +440,6 @@ siftup_max(PyListObject *heap, Py_ssize_t pos) } } /* Move the smaller child up. */ - arr = _PyList_ITEMS(heap); tmp1 = arr[childpos]; tmp2 = arr[pos]; arr[childpos] = tmp2; |