Skip to content

Commit

Permalink
Avoid boxing in DeferredDisposableLifetime (#79778)
Browse files Browse the repository at this point in the history
* Avoid boxing in DeferredDisposableLifetime

* Move `typeof` lookup behind the if check
  • Loading branch information
MihaZupan authored Dec 17, 2022
1 parent c6045ad commit 56e22a4
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ public bool AddRef()
int oldCount = Volatile.Read(ref _count);

// Have we been disposed?
ObjectDisposedException.ThrowIf(oldCount < 0, this);
if (oldCount < 0)
throw new ObjectDisposedException(typeof(T).ToString());

int newCount = checked(oldCount + 1);

Expand Down

0 comments on commit 56e22a4

Please sign in to comment.