mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
Issue #24221: Small optimizations for heapq.
Replaces the PyList_GET_ITEM and PyList_SET_ITEM macros with normal array accesses. Replace the siftup unpredicatable branch with arithmetic. Replace the rc == -1 tests with rc < 0. Gives nicer looking assembly with both Clang and GCC-4.9. Also gives a small performance both for both.
This commit is contained in:
parent
35e24a50c5
commit
5cbd8331ff
2 changed files with 44 additions and 37 deletions
|
@ -72,6 +72,7 @@ PyAPI_FUNC(void) _PyList_DebugMallocStats(FILE *out);
|
|||
#define PyList_GET_ITEM(op, i) (((PyListObject *)(op))->ob_item[i])
|
||||
#define PyList_SET_ITEM(op, i, v) (((PyListObject *)(op))->ob_item[i] = (v))
|
||||
#define PyList_GET_SIZE(op) Py_SIZE(op)
|
||||
#define _PyList_ITEMS(op) (((PyListObject *)(op))->ob_item)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue