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 unused custom incref/decref
  • Loading branch information
filmor committed Oct 4, 2023
commit 93d4119205a97d3631896e2163f145cd28b24c20
46 changes: 0 additions & 46 deletions src/runtime/Runtime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -598,23 +598,8 @@ internal static void CheckExceptionOccurred()
[Obsolete("Use NewReference or PyObject constructor instead")]
internal static unsafe void XIncref(BorrowedReference op)
{
#if !CUSTOM_INCDEC_REF
Py_IncRef(op);
return;
#else
var p = (void*)op;
if ((void*)0 != p)
{
if (Is32Bit)
{
(*(int*)p)++;
}
else
{
(*(long*)p)++;
}
}
#endif
}

internal static unsafe void XDecref(StolenReference op)
Expand All @@ -623,40 +608,9 @@ internal static unsafe void XDecref(StolenReference op)
Debug.Assert(op == null || Refcount(new BorrowedReference(op.Pointer)) > 0);
Debug.Assert(_isInitialized || Py_IsInitialized() != 0 || _Py_IsFinalizing() != false);
#endif
#if !CUSTOM_INCDEC_REF
if (op == null) return;
Py_DecRef(op.AnalyzerWorkaround());
return;
#else
var p = (void*)op;
if ((void*)0 != p)
{
if (Is32Bit)
{
--(*(int*)p);
}
else
{
--(*(long*)p);
}
if ((*(int*)p) == 0)
{
// PyObject_HEAD: struct _typeobject *ob_type
void* t = Is32Bit
? (void*)(*((uint*)p + 1))
: (void*)(*((ulong*)p + 1));
// PyTypeObject: destructor tp_dealloc
void* f = Is32Bit
? (void*)(*((uint*)t + 6))
: (void*)(*((ulong*)t + 6));
if ((void*)0 == f)
{
return;
}
NativeCall.Void_Call_1(new IntPtr(f), op);
}
}
#endif
}

[Pure]
Expand Down