Skip to content

Commit

Permalink
Removed nullable separator parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
bbartels committed Jun 18, 2020
1 parent 1b73a5d commit 2b0b8f8
Showing 1 changed file with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1579,7 +1579,7 @@ private void MakeSeparatorList(ReadOnlySpan<char> separators, ref ValueListBuild

if (Avx2.IsSupported && Length >= 16)
{
MakeSeparatorListVectorized(ref sepListBuilder, sep0);
MakeSeparatorListVectorized(ref sepListBuilder, sep0, sep0, sep0);
return;
}

Expand All @@ -1597,7 +1597,7 @@ private void MakeSeparatorList(ReadOnlySpan<char> separators, ref ValueListBuild

if (Avx2.IsSupported && Length >= 16)
{
MakeSeparatorListVectorized(ref sepListBuilder, sep0, sep1);
MakeSeparatorListVectorized(ref sepListBuilder, sep0, sep1, sep1);
return;
}

Expand Down Expand Up @@ -1654,10 +1654,8 @@ private void MakeSeparatorList(ReadOnlySpan<char> separators, ref ValueListBuild
}
}

private void MakeSeparatorListVectorized(ref ValueListBuilder<int> sepListBuilder, char c, char? c2 = null, char? c3 = null)
private void MakeSeparatorListVectorized(ref ValueListBuilder<int> sepListBuilder, char c, char c2, char c3)
{
// Constant that defines indices of characters within an AVX-Register
const ulong indicesConstant = 0xFEDCBA9876543210;
// Constant that allows for the truncation of 16-bit (FFFF/0000) values within a register to 4-bit (F/0)
Vector256<byte> shuffleConstant = Vector256.Create(0x02, 0x06, 0x0A, 0x0E, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0x02, 0x06, 0x0A, 0x0E, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF);
Expand All @@ -1684,6 +1682,9 @@ private void MakeSeparatorListVectorized(ref ValueListBuilder<int> sepListBuilde
mask = Avx2.Shuffle(mask, shuffleConstant);

Vector128<byte> res = Sse2.Or(mask.GetLower(), mask.GetUpper());

// Constant that defines indices of characters within an AVX-Register
const ulong indicesConstant = 0xFEDCBA9876543210;
ulong extractedBits = Bmi2.X64.ParallelBitExtract(indicesConstant, Sse2.X64.ConvertToUInt64(res.AsUInt64()));

while (true)
Expand All @@ -1696,8 +1697,8 @@ private void MakeSeparatorListVectorized(ref ValueListBuilder<int> sepListBuilde

for (; i < Length; i++)
{
char curr = this[i];
if (curr == c || (c2 != null && curr == c2) || (c3 != null && curr == c3))
char curr = Unsafe.Add(ref c0, (IntPtr)(uint)i);
if (curr == c || curr == c2 || curr == c3)
{
sepListBuilder.Append(i);
}
Expand Down

0 comments on commit 2b0b8f8

Please sign in to comment.