Skip to content
This repository was archived by the owner on Apr 8, 2025. It is now read-only.

Commit 3ed61b3

Browse files
committed
f
1 parent 2f3903b commit 3ed61b3

3 files changed

Lines changed: 15 additions & 11 deletions

File tree

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Numerics;
1+
using System.Diagnostics.CodeAnalysis;
2+
using System.Numerics;
23

34
namespace SimdLinq;
45

@@ -7,10 +8,7 @@ public static partial class SimdLinqExtensions
78
static T AverageCore<T>(ReadOnlySpan<T> source)
89
where T : struct, INumber<T>
910
{
10-
if(source.IsEmpty)
11-
{
12-
throw new InvalidOperationException("Sequence contains no elements");
13-
}
11+
if (source.IsEmpty) ThrowNoElements();
1412
return T.CreateChecked(SumCore(source)) / T.CreateChecked(source.Length);
1513
}
1614
}

src/SimdLinq/SimdLinqExtensions.MinMaxCore.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -239,10 +239,4 @@ static T MaxCore<T>(ReadOnlySpan<T> source)
239239
return (min, max);
240240
}
241241
}
242-
243-
[DoesNotReturn]
244-
static void ThrowNoElements()
245-
{
246-
throw new InvalidOperationException("Sequence contains no elements");
247-
}
248242
}

src/SimdLinq/SimdLinqExtensions.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using System.Diagnostics.CodeAnalysis;
2+
3+
namespace SimdLinq;
4+
5+
public static partial class SimdLinqExtensions
6+
{
7+
[DoesNotReturn]
8+
static void ThrowNoElements()
9+
{
10+
throw new InvalidOperationException("Sequence contains no elements");
11+
}
12+
}

0 commit comments

Comments
 (0)