Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit c27dca7

Browse files
committed
Check for state before fetching threadID
It is unlikely that fetching CurrentManagedThreadId is cheaper than fetching an int field, so lets check the state first.
1 parent bb68d15 commit c27dca7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/System.Linq/src/System/Linq/Enumerable.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public virtual void Dispose()
100100

101101
public IEnumerator<TSource> GetEnumerator()
102102
{
103-
if (_threadId == Environment.CurrentManagedThreadId && state == 0)
103+
if (state == 0 && _threadId == Environment.CurrentManagedThreadId)
104104
{
105105
state = 1;
106106
return this;

0 commit comments

Comments
 (0)