Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Drop has_own_refchain() calls where not needed.
  • Loading branch information
ericsnowcurrently committed Oct 21, 2024
commit ffe263370fe0ac0f2c5bde12821775b8943eb24f
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