summaryrefslogtreecommitdiffstats
path: root/Objects/object.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2020-02-03 16:55:05 (GMT)
committerGitHub <noreply@github.com>2020-02-03 16:55:04 (GMT)
commit49932fec62c616ec88da52642339d83ae719e924 (patch)
treeb489d2b97cf56c0b51a15f27ecf4064c5084d9d8 /Objects/object.c
parent24e5ad4689de9adc8e4a7d8c08fe400dcea668e6 (diff)
downloadcpython-49932fec62c616ec88da52642339d83ae719e924.zip
cpython-49932fec62c616ec88da52642339d83ae719e924.tar.gz
cpython-49932fec62c616ec88da52642339d83ae719e924.tar.bz2
bpo-39542: Simplify _Py_NewReference() (GH-18332)
* Remove _Py_INC_REFTOTAL and _Py_DEC_REFTOTAL macros: modify directly _Py_RefTotal. * _Py_ForgetReference() is no longer defined if the Py_TRACE_REFS macro is not defined. * Remove _Py_NewReference() implementation from object.c: unify the two implementations in object.h inline function. * Fix Py_TRACE_REFS build: _Py_INC_TPALLOCS() macro has been removed.
Diffstat (limited to 'Objects/object.c')
-rw-r--r--Objects/object.c21
1 files changed, 5 insertions, 16 deletions
diff --git a/Objects/object.c b/Objects/object.c
index 2154d11..085605a 100644
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -232,9 +232,11 @@ PyObject_CallFinalizerFromDealloc(PyObject *self)
_PyObject_ASSERT(self,
(!PyType_IS_GC(Py_TYPE(self))
|| _PyObject_GC_IS_TRACKED(self)));
- /* If Py_REF_DEBUG, _Py_NewReference bumped _Py_RefTotal, so
- * we need to undo that. */
- _Py_DEC_REFTOTAL;
+ /* If Py_REF_DEBUG macro is defined, _Py_NewReference() increased
+ _Py_RefTotal, so we need to undo that. */
+#ifdef Py_REF_DEBUG
+ _Py_RefTotal--;
+#endif
return -1;
}
@@ -1804,19 +1806,6 @@ _PyTypes_Init(void)
#ifdef Py_TRACE_REFS
-
-void
-_Py_NewReference(PyObject *op)
-{
- if (_Py_tracemalloc_config.tracing) {
- _PyTraceMalloc_NewReference(op);
- }
- _Py_INC_REFTOTAL;
- op->ob_refcnt = 1;
- _Py_AddToAllObjects(op, 1);
- _Py_INC_TPALLOCS(op);
-}
-
void
_Py_ForgetReference(PyObject *op)
{