From 6fdb82aea93465ee046c7f903a96d5c2027a3ecd Mon Sep 17 00:00:00 2001 From: Stephen Toub Date: Mon, 28 Jun 2021 10:42:53 -0400 Subject: [PATCH] Reduce overhead of Enumerable.Chunk (#54782) Avoid passing the array by ref and yielding inside the loop, which defeat various optimizations (e.g. bounds checking elimination). --- .../System.Linq/src/System/Linq/Chunk.cs | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/libraries/System.Linq/src/System/Linq/Chunk.cs b/src/libraries/System.Linq/src/System/Linq/Chunk.cs index 661edaab5694a..2a2ddd44961bc 100644 --- a/src/libraries/System.Linq/src/System/Linq/Chunk.cs +++ b/src/libraries/System.Linq/src/System/Linq/Chunk.cs @@ -55,20 +55,23 @@ private static IEnumerable ChunkIterator(IEnumerable