Skip to content

Commit 56e22a4

Browse files
authored
Avoid boxing in DeferredDisposableLifetime (#79778)
* Avoid boxing in DeferredDisposableLifetime * Move `typeof` lookup behind the if check
1 parent c6045ad commit 56e22a4

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/libraries/System.Private.CoreLib/src/System/Threading/DeferredDisposableLifetime.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ public bool AddRef()
5050
int oldCount = Volatile.Read(ref _count);
5151

5252
// Have we been disposed?
53-
ObjectDisposedException.ThrowIf(oldCount < 0, this);
53+
if (oldCount < 0)
54+
throw new ObjectDisposedException(typeof(T).ToString());
5455

5556
int newCount = checked(oldCount + 1);
5657

0 commit comments

Comments
 (0)