CommunityToolkit / dotnet

.NET Community Toolkit is a collection of helpers and APIs that work for all .NET developers and are agnostic of any specific UI platform. The toolkit is maintained and published by Microsoft, and part of the .NET Foundation.
https://docs.microsoft.com/dotnet/communitytoolkit/?WT.mc_id=dotnet-0000-bramin
Other
3.07k stars 299 forks source link

Remove unnecessary temporary array allocation #719

Closed Sergio0694 closed 1 year ago

Sergio0694 commented 1 year ago

Overview

This PR adds an API to enumerate items in an array builder without allocating a whole array. It also uses this API when creating a BlockSyntax, to avoid wasting an array just to enumerate items. The returned enumerable is readonly, ensuring mutations must go through the actual builder.

PR Checklist

Sergio0694 commented 1 year ago

Hey @Youssef1313, want to take a quick lock when you have a minute? This one is very smol 😄

Sergio0694 commented 1 year ago

@Youssef1313 I assume you have no other concerns with this one, so good to go? 😄