dotnet/runtime

TakeLast Performance Improvement suggestion

オープン

#118,312 opened on 2025/08/03

 (3 件のコメント) (0 件のリアクション) (0 人の担当者)C# (5,445 件のフォーク)batch import
area-System.Linqhelp wantedtenet-performance

Repository metrics

Stars
 (17,886 個のスター)
PR merge metrics
 (PR metrics pending)

説明

TakeRangeFromEndIterator uses a regular Queue <T>when IsStartIndexFromEnd, but this process can be done without intervening yields, allowing optimization using ArrayPool and Span.

https://github.com/dotnet/runtime/blob/3f25a276772b8d0e54452321e7525b7a176aa4a7/src/libraries/System.Linq/src/System/Linq/Take.cs#L111C13-L154C18

Below is the PR I did on ZLinq. https://github.com/Cysharp/ZLinq/pull/207/files Unlike ZLinq, a ToArray is required at the end of the queueing for Linq, but it will be similar.

コントリビューターガイド