Skip to content

Commit

Permalink
Drop has_own_refchain() calls where not needed.
Browse files Browse the repository at this point in the history
  • Loading branch information
ericsnowcurrently committed Oct 21, 2024
1 parent 203c112 commit ffe2633
Showing 1 changed file with 0 additions and 18 deletions.
18 changes: 0 additions & 18 deletions Objects/object.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,19 +215,13 @@ refchain_fini(PyInterpreterState *interp)
bool
_PyRefchain_IsTraced(PyInterpreterState *interp, PyObject *obj)
{
if (!has_own_refchain(interp)) {
interp = _PyInterpreterState_Main();
}
return (_Py_hashtable_get(REFCHAIN(interp), obj) == REFCHAIN_VALUE);
}


static void
_PyRefchain_Trace(PyInterpreterState *interp, PyObject *obj)
{
if (!has_own_refchain(interp)) {
interp = _PyInterpreterState_Main();
}
if (_Py_hashtable_set(REFCHAIN(interp), obj, REFCHAIN_VALUE) < 0) {
// Use a fatal error because _Py_NewReference() cannot report
// the error to the caller.
Expand All @@ -239,9 +233,6 @@ _PyRefchain_Trace(PyInterpreterState *interp, PyObject *obj)
static void
_PyRefchain_Remove(PyInterpreterState *interp, PyObject *obj)
{
if (!has_own_refchain(interp)) {
interp = _PyInterpreterState_Main();
}
void *value = _Py_hashtable_steal(REFCHAIN(interp), obj);
#ifndef NDEBUG
assert(value == REFCHAIN_VALUE);
Expand Down Expand Up @@ -2587,9 +2578,6 @@ _Py_PrintReferences(PyInterpreterState *interp, FILE *fp)
interp = _PyInterpreterState_Main();
}
fprintf(fp, "Remaining objects:\n");
if (!has_own_refchain(interp)) {
interp = _PyInterpreterState_Main();
}
_Py_hashtable_foreach(REFCHAIN(interp), _Py_PrintReference, fp);
}

Expand Down Expand Up @@ -2618,9 +2606,6 @@ void
_Py_PrintReferenceAddresses(PyInterpreterState *interp, FILE *fp)
{
fprintf(fp, "Remaining object addresses:\n");
if (!has_own_refchain(interp)) {
interp = _PyInterpreterState_Main();
}
_Py_hashtable_foreach(REFCHAIN(interp), _Py_PrintReferenceAddress, fp);
}

Expand Down Expand Up @@ -2700,9 +2685,6 @@ _Py_GetObjects(PyObject *self, PyObject *args)
.limit = limit,
};
PyInterpreterState *interp = _PyInterpreterState_GET();
if (!has_own_refchain(interp)) {
interp = _PyInterpreterState_Main();
}
int res = _Py_hashtable_foreach(REFCHAIN(interp), _Py_GetObject, &data);
if (res == _PY_GETOBJECTS_ERROR) {
Py_DECREF(list);
Expand Down

0 comments on commit ffe2633

Please sign in to comment.