Improve throw path in ReferenceTracker

このコミットが含まれているのは:
Sergio Pedri committed 2023-11-05 16:41:31 +01:00
1 親 bef1bb802b
コミット 5eda154570
1ファイル変更
+1 -9
+1 -9
ファイルの表示
@@ -115,15 +115,7 @@ internal struct ReferenceTracker : IDisposable
{
Lease lease = TryGetLease(out bool leaseTaken);
if (!leaseTaken)
{
// We can't use a throw helper here as we only want to invoke ToString if we
// are about to throw an exception. The JIT will recognize this pattern
// as this method has a single basic block that always throws an exception.
static void Throw(object trackedObject) => throw new ObjectDisposedException(trackedObject.ToString());
Throw(this);
}
default(ObjectDisposedException).ThrowIf(!leaseTaken, this.trackedObject);
return lease;
}