diff options
author | Campbell Barton <ideasman42@gmail.com> | 2015-01-06 09:39:47 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2015-01-06 11:09:53 +0300 |
commit | bf0c8e116db49379900020b5a20ba15d91b3fb9a (patch) | |
tree | c65b43084bde562dc2a08b5d88cb128f09028b6b /source/blender/python/generic/python_utildefines.h | |
parent | 9fd569a654ded46901c7f20c5fe080972cbb10d2 (diff) |
PyAPI: add PyList_APPEND
This appends while giving ownership to the list, avoiding temp assignment.
This matches PyList_SET_ITEM which bypasses refcount's
Note, this also reduce code-size, Py_DECREF is a rather heavy macro.
Diffstat (limited to 'source/blender/python/generic/python_utildefines.h')
-rw-r--r-- | source/blender/python/generic/python_utildefines.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/source/blender/python/generic/python_utildefines.h b/source/blender/python/generic/python_utildefines.h index 555ad4819eb..f7d3e7a8b4a 100644 --- a/source/blender/python/generic/python_utildefines.h +++ b/source/blender/python/generic/python_utildefines.h @@ -44,6 +44,14 @@ extern "C" { * use sparingly to avoid comma operator or temp var assignment */ BLI_INLINE PyObject *Py_INCREF_RET(PyObject *op) { Py_INCREF(op); return op; } +/* append & transfer ownership to the list, avoids inline Py_DECREF all over (which is quite a large macro) */ +BLI_INLINE int PyList_APPEND(PyObject *op, PyObject *v) +{ + int ret = PyList_Append(op, v); + Py_DecRef(v); + return ret; +} + #ifdef __cplusplus } #endif |