jackmott / LinqFaster

Linq-like extension functions for Arrays, Span<T>, and List<T> that are faster and allocate less.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add support for Span<T>

jackmott opened this issue · comments

We should add support for Span, which would allow the use of these functions on stackalloc arrays and other memory sources. If we targeted only .NET 2.0 we could change the function signatures of all methods taking arrays to Spans, but if we want to support .NET Framework and Core 1.0 we need to duplicate every array function, and make a Span version.

As well, performance opportunities may exist if we use stackalloc arrays when appropriate inside our implementations.

More research on this:
If we merely changed all array methods to take spans, then people using LinqFaster from .NET Framework would take a big performance hit. So we would need to duplicate each function to have array and span versions. Maybe something that could be automated, as it is a lot of grunt work.

span support added

Any plans to support ReadOnlySpan<T> too? As of now, it looks like the work of duplicating the functions isn't automated.

Any plans to support ReadOnlySpan<T> too? As of now, it looks like the work of duplicating the functions isn't automated.

See "https://github.com/Smurf-IV/LinqFaster"

@BrunoZell if you could open a new issue for that? It seems a bit (related but) tangential to this one
@Smurf-IV if you could break up the review that'd be wonderful :-P Or specific exactly what features to add, so that someone else can add them as smaller reviews that can be reviewed with higher precision/recall (due to better focus area of change)