Skip to content

Commit 9942e44

Browse files
committed
Merge branch 'feature-improved-Split' into dev
2 parents df19b2e + 12a1c4b commit 9942e44

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+2675
-57
lines changed

.editorconfig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ csharp_style_var_elsewhere = false:suggestion
5151
dotnet_diagnostic.CA1001.severity = warning
5252
dotnet_diagnostic.CA1309.severity = warning
5353
dotnet_diagnostic.CA1510.severity = none
54-
csharp_style_prefer_primary_constructors = false:error
54+
csharp_style_prefer_primary_constructors = false:suggestion
5555
dotnet_diagnostic.CA1311.severity = warning
5656
dotnet_diagnostic.SYSLIB1054.severity = warning
5757
dotnet_diagnostic.CA1805.severity = suggestion
@@ -115,7 +115,7 @@ dotnet_style_object_initializer = true:suggestion
115115
dotnet_style_collection_initializer = true:suggestion
116116
dotnet_style_prefer_simplified_boolean_expressions = true:suggestion
117117
dotnet_style_prefer_conditional_expression_over_assignment = true:suggestion
118-
dotnet_style_prefer_conditional_expression_over_return = true:suggestion
118+
dotnet_style_prefer_conditional_expression_over_return = false:suggestion
119119
dotnet_style_operator_placement_when_wrapping = beginning_of_line
120120
tab_width = 4
121121
indent_size = 4

.gitattributes

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
* text=auto
2+
3+
*.cs text diff=csharp
4+
5+
*.sln text eol=crlf merge=binary
6+
*.csproj merge=binary

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ jobs:
2626
- name: Build
2727
run: dotnet build --no-restore
2828
- name: Test
29-
run: dotnet test --no-build --verbosity normal
29+
run: dotnet test --no-build --verbosity normal --filter FullyQualifiedName!~SpanExtensions.Tests.Fuzzing

SpanExtensions.sln

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ VisualStudioVersion = 17.5.33627.172
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SpanExtensions", "src\SpanExtensions.csproj", "{75DE5AFD-663E-415D-9B95-6BC513BD4A07}"
77
EndProject
8+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnitTests", "tests\unit-tests\UnitTests.csproj", "{B48A0293-A7FF-4E39-8F8D-57B6F824D70F}"
9+
EndProject
10+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PerformanceTests", "tests\Performance\PerformanceTests.csproj", "{CE74F420-1038-4E51-AC31-00DA964CC4F5}"
11+
EndProject
812
Global
913
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1014
Debug|Any CPU = Debug|Any CPU
@@ -15,6 +19,14 @@ Global
1519
{75DE5AFD-663E-415D-9B95-6BC513BD4A07}.Debug|Any CPU.Build.0 = Debug|Any CPU
1620
{75DE5AFD-663E-415D-9B95-6BC513BD4A07}.Release|Any CPU.ActiveCfg = Release|Any CPU
1721
{75DE5AFD-663E-415D-9B95-6BC513BD4A07}.Release|Any CPU.Build.0 = Release|Any CPU
22+
{B48A0293-A7FF-4E39-8F8D-57B6F824D70F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
23+
{B48A0293-A7FF-4E39-8F8D-57B6F824D70F}.Debug|Any CPU.Build.0 = Debug|Any CPU
24+
{B48A0293-A7FF-4E39-8F8D-57B6F824D70F}.Release|Any CPU.ActiveCfg = Release|Any CPU
25+
{B48A0293-A7FF-4E39-8F8D-57B6F824D70F}.Release|Any CPU.Build.0 = Release|Any CPU
26+
{CE74F420-1038-4E51-AC31-00DA964CC4F5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27+
{CE74F420-1038-4E51-AC31-00DA964CC4F5}.Debug|Any CPU.Build.0 = Debug|Any CPU
28+
{CE74F420-1038-4E51-AC31-00DA964CC4F5}.Release|Any CPU.ActiveCfg = Release|Any CPU
29+
{CE74F420-1038-4E51-AC31-00DA964CC4F5}.Release|Any CPU.Build.0 = Release|Any CPU
1830
EndGlobalSection
1931
GlobalSection(SolutionProperties) = preSolution
2032
HideSolutionNode = FALSE

src/Extensions/ReadOnlySpan/Linq/AsEnumerable.cs

Lines changed: 0 additions & 24 deletions
This file was deleted.

src/Extensions/ReadOnlySpan/Linq/Where.cs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@ public static partial class ReadOnlySpanExtensions
1515
/// <exception cref="ArgumentNullException"><paramref name="predicate"/> is null.</exception>
1616
public static IEnumerable<T> Where<T>(this ReadOnlySpan<T> source, Predicate<T> predicate)
1717
{
18-
ReadOnlySpan<T>.Enumerator e = source.GetEnumerator();
18+
List<T> list = new List<T>();
1919

20-
while(e.MoveNext())
20+
foreach (T current in source)
2121
{
22-
T current = e.Current;
23-
24-
if(predicate(current))
22+
if(predicate(current))
2523
{
26-
yield return current;
24+
list.Add(current);
2725
}
2826
}
27+
28+
return list;
2929
}
3030

3131
/// <summary>
@@ -38,15 +38,19 @@ public static IEnumerable<T> Where<T>(this ReadOnlySpan<T> source, Predicate<T>
3838
/// <exception cref="ArgumentNullException"><paramref name="predicate"/> is null.</exception>
3939
public static IEnumerable<T> Where<T>(this ReadOnlySpan<T> source, Func<T, int, bool> predicate)
4040
{
41+
List<T> list = new List<T>();
42+
4143
for(int i = 0; i < source.Length; i++)
4244
{
4345
T current = source[i];
4446

4547
if(predicate(current, i))
4648
{
47-
yield return current;
49+
list.Add(current);
4850
}
4951
}
52+
53+
return list;
5054
}
5155
}
5256
}

src/Extensions/Span/Linq/AsEnumerable.cs

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/Extensions/Span/String/Split.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public static SpanSplitStringSplitOptionsEnumerator Split(this Span<char> source
5454
/// <param name="options">A bitwise combination of the enumeration values that specifies whether to trim results and include empty results.</param>
5555
/// <param name="countExceedingBehaviour">The handling of the instances more than count.</param>
5656
/// <returns>An instance of the ref struct <see cref="SpanSplitAnyStringSplitOptionsWithCountEnumerator"/>, which works the same way as every <see cref="IEnumerator"/> does and can be used in a foreach construct.</returns>
57-
public static SpanSplitStringSplitOptionsWithCountEnumerator Split(this Span<char> source, char delimiter, StringSplitOptions options, int count, CountExceedingBehaviour countExceedingBehaviour = CountExceedingBehaviour.AppendRemainingElements)
57+
public static SpanSplitStringSplitOptionsWithCountEnumerator Split(this Span<char> source, char delimiter, int count, StringSplitOptions options, CountExceedingBehaviour countExceedingBehaviour = CountExceedingBehaviour.AppendRemainingElements)
5858
{
5959
return new SpanSplitStringSplitOptionsWithCountEnumerator(source, delimiter, count, options, countExceedingBehaviour);
6060
}

src/Extensions/Span/String/SplitAny.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public static SpanSplitAnyStringSplitOptionsEnumerator SplitAny(this Span<char>
5353
/// <param name="count">The maximum number of sub-ReadOnlySpans to split into.</param>
5454
/// <param name="countExceedingBehaviour">The handling of the instances more than count.</param>
5555
/// <returns>An instance of the ref struct <see cref="SpanSplitAnyStringSplitOptionsWithCountEnumerator"/>, which works the same way as every <see cref="IEnumerator"/> does and can be used in a foreach construct.</returns>
56-
public static SpanSplitAnyStringSplitOptionsWithCountEnumerator SplitAny(this Span<char> source, ReadOnlySpan<char> delimiters, StringSplitOptions options, int count, CountExceedingBehaviour countExceedingBehaviour = CountExceedingBehaviour.AppendRemainingElements)
56+
public static SpanSplitAnyStringSplitOptionsWithCountEnumerator SplitAny(this Span<char> source, ReadOnlySpan<char> delimiters, int count, StringSplitOptions options, CountExceedingBehaviour countExceedingBehaviour = CountExceedingBehaviour.AppendRemainingElements)
5757
{
5858
return new SpanSplitAnyStringSplitOptionsWithCountEnumerator(source, delimiters, count, options, countExceedingBehaviour);
5959
}

src/Extensions/Span/String/SplitSequence.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public static SpanSplitSequenceStringSplitOptionsEnumerator Split(this Span<char
5656
/// <param name="options">A bitwise combination of the enumeration values that specifies whether to trim results and include empty results.</param>
5757
/// <param name="countExceedingBehaviour">The handling of the instances more than count.</param>
5858
/// <returns>An instance of the ref struct <see cref="SpanSplitSequenceStringSplitOptionsWithCountEnumerator"/>, which works the same way as every <see cref="IEnumerator"/> does and can be used in a foreach construct.</returns>
59-
public static SpanSplitSequenceStringSplitOptionsWithCountEnumerator Split(this Span<char> source, ReadOnlySpan<char> delimiter, StringSplitOptions options, int count, CountExceedingBehaviour countExceedingBehaviour = CountExceedingBehaviour.AppendRemainingElements)
59+
public static SpanSplitSequenceStringSplitOptionsWithCountEnumerator Split(this Span<char> source, ReadOnlySpan<char> delimiter, int count, StringSplitOptions options, CountExceedingBehaviour countExceedingBehaviour = CountExceedingBehaviour.AppendRemainingElements)
6060
{
6161
return new SpanSplitSequenceStringSplitOptionsWithCountEnumerator(source, delimiter, count, options, countExceedingBehaviour);
6262
}

0 commit comments

Comments
 (0)