dotnet/runtime

TakeLast Performance Improvement suggestion

開放

#118,312 建立於 2025年8月3日

 (3 則留言) (0 個反應) (0 位負責人)C# (5,445 個分叉)batch import
area-System.Linqhelp wantedtenet-performance

倉庫指標

星標
 (17,886 顆星)
PR 合併指標
 (PR 指標待抓取)

描述

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.

貢獻者指南