dotnet/runtime

TakeLast Performance Improvement suggestion

Open

#118,312 创建于 2025年8月3日

在 GitHub 查看
 (3 评论) (0 反应) (0 负责人)C# (17,886 star) (5,445 fork)batch import
area-System.Linqhelp wantedtenet-performance

描述

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.

贡献者指南

TakeLast Performance Improvement suggestion · dotnet/runtime#118312 | Good First Issue