High-performance LINQ-style operations using value-type enumerables and span-based extensions with zero allocations.
- ✅ Zero Allocations - Span-based operations with ref struct enumerators
- ✅ SIMD Optimization - Vectorized operations for numeric types
- ✅ Generic Math -
Sum()works with any numeric type (int, double, BigInteger, etc.) - ✅ Operation Fusion - Automatic fusion of
Where().Select().Sum()chains - ✅ Pooled Memory -
ToArrayPooled()to reduce GC pressure - ✅ Roslyn Analyzer - Suggests optimizations automatically
dotnet add package NetFabric.Hyperlinqusing NetFabric.Hyperlinq; // Required for arrays, spans, memory, and List<T>
int[] numbers = { 1, 2, 3, 4, 5 };
var sum = numbers.Sum(); // SIMD-optimized, zero allocations
// For IEnumerable<T>, use AsValueEnumerable()
IEnumerable<int> enumerable = GetNumbers();
var result = enumerable.AsValueEnumerable()
.Where(x => x > 0)
.Select(x => x * 2)
.Sum(); // Fused into single pass!Compared to standard LINQ:
- 50-55% faster for
IEnumerableWhere/WhereSelect operations - 26% faster for Sum operations on arrays/lists
- Up to 75% less memory allocated
See benchmarks for detailed results.
| Type | Usage | Performance |
|---|---|---|
T[] |
Direct | Fastest - SIMD optimized |
Span<T> / ReadOnlySpan<T> |
Direct | Zero allocations |
Memory<T> / ReadOnlyMemory<T> |
Direct | Zero allocations |
List<T> |
Direct | Zero-copy via CollectionsMarshal |
IEnumerable<T> |
.AsValueEnumerable() |
Struct enumerators |
- Getting Started - Installation and quick start
- Guides - In-depth usage guides
- Architecture - Design principles and internals
- API Reference - Complete API documentation
- Benchmarks - Performance benchmarks
Contributions are welcome! Please read the Contributing Guide and check out the development guidelines.
- .NET 10 or later
- C# 14 language features
This project is licensed under the MIT License - see the LICENSE file for details.
Copyright (c) 2025 Antão Almada
using System.Numerics;
// Works with any numeric type!
double[] doubles = { 1.5, 2.5, 3.5 };
var doubleSum = doubles.Sum(); // 7.5
BigInteger[] bigInts = { new(1), new(2), new(3) };
var bigSum = bigInts.Sum(); // 6Reduce GC pressure by using pooled buffers for temporary materialization:
using NetFabric.Hyperlinq;
var largeArray = GetLargeArray();
// Materialize to a pooled buffer instead of allocating a new array
using var buffer = largeArray.AsSpan()
.Where(x => x % 2 == 0)
.ToArrayPooled(); // Returns PooledBuffer<T>
// Use the buffer
Process(buffer.AsSpan());
// Buffer is automatically returned to the pool when disposedGenerate sequences efficiently with zero-allocation enumeration:
using NetFabric.Hyperlinq;
// Generate a range of integers
var range = ValueEnumerable.Range(0, 100);
// Supports indexing (IValueReadOnlyList)
var tenth = range[10]; // 10
// Materialization is SIMD-optimized for Range and Repeat!
// Uses Vector<T> for ToArray(), ToList(), and CopyTo()
var array = range.ToArray(); // No resizing needed, blazingly fast
// Chain operations
var evenSquares = range
.Where(x => x % 2 == 0)
.Select(x => x * x)
.ToArray();The analyzer automatically suggests optimizations:
var list = new List<int> { 1, 2, 3 };
var result = list.Where(x => x > 1); // ⚠️ Analyzer suggests: Use AsValueEnumerable()
// After fix:
var result = list.AsValueEnumerable().Where(x => x > 1); // ✅ Optimized!Built with ❤️ for high-performance .NET applications