projects
/
platform
/
upstream
/
dotnet
/
runtime.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
29d8a16
)
Simplify SelectArrayIterator method (#85695)
author
Stephen Toub
<stoub@microsoft.com>
Wed, 3 May 2023 20:51:32 +0000
(13:51 -0700)
committer
GitHub
<noreply@github.com>
Wed, 3 May 2023 20:51:32 +0000
(13:51 -0700)
src/libraries/System.Linq/src/System/Linq/Select.cs
patch
|
blob
|
history
diff --git
a/src/libraries/System.Linq/src/System/Linq/Select.cs
b/src/libraries/System.Linq/src/System/Linq/Select.cs
index 791363496f68b1d7c4017f679ef589918c74342f..9d3dcc45b05f3bbd0069d05e21a088c4555e4479 100644
(file)
--- a/
src/libraries/System.Linq/src/System/Linq/Select.cs
+++ b/
src/libraries/System.Linq/src/System/Linq/Select.cs
@@
-178,15
+178,17
@@
namespace System.Linq
public override bool MoveNext()
{
- if (_state < 1 | _state == _source.Length + 1)
+ TSource[] source = _source;
+ int index = _state - 1;
+ if ((uint)index < (uint)source.Length)
{
- Dispose();
- return false;
+ _state++;
+ _current = _selector(source[index]);
+ return true;
}
- int index = _state++ - 1;
- _current = _selector(_source[index]);
- return true;
+ Dispose();
+ return false;
}
public override IEnumerable<TResult2> Select<TResult2>(Func<TResult, TResult2> selector) =>