Skip to content

Commit 57fc73d

Browse files
committed
Updating Utf16Utility.Validation to directly use Vector<nuint>
1 parent 35764d7 commit 57fc73d

File tree

1 file changed

+2
-20
lines changed

1 file changed

+2
-20
lines changed

src/libraries/System.Private.CoreLib/src/System/Text/Unicode/Utf16Utility.Validation.cs

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,10 @@
1212
using Internal.Runtime.CompilerServices;
1313
#endif
1414

15-
#pragma warning disable SA1121 // explicitly using type aliases instead of built-in types
16-
#if SYSTEM_PRIVATE_CORELIB
17-
#if TARGET_64BIT
18-
using nuint_t = System.UInt64;
19-
#else // TARGET_64BIT
20-
using nuint_t = System.UInt32;
21-
#endif // TARGET_64BIT
22-
#else
23-
using nuint_t = System.UInt64;
24-
#endif
25-
2615
namespace System.Text.Unicode
2716
{
2817
internal static unsafe partial class Utf16Utility
2918
{
30-
#if DEBUG && SYSTEM_PRIVATE_CORELIB
31-
static Utf16Utility()
32-
{
33-
Debug.Assert(sizeof(nuint_t) == IntPtr.Size && nuint.MinValue == 0, "nuint_t is defined incorrectly.");
34-
}
35-
#endif // DEBUG && SYSTEM_PRIVATE_CORELIB
36-
3719
// Returns &inputBuffer[inputLength] if the input buffer is valid.
3820
/// <summary>
3921
/// Given an input buffer <paramref name="pInputBuffer"/> of char length <paramref name="inputLength"/>,
@@ -341,13 +323,13 @@ static Utf16Utility()
341323
Vector<ushort> utf16Data = Unsafe.ReadUnaligned<Vector<ushort>>(pInputBuffer);
342324
Vector<ushort> twoOrMoreUtf8Bytes = Vector.GreaterThanOrEqual(utf16Data, vector0080);
343325
Vector<ushort> threeOrMoreUtf8Bytes = Vector.GreaterThanOrEqual(utf16Data, vector0800);
344-
Vector<nuint_t> sumVector = (Vector<nuint_t>)(Vector<ushort>.Zero - twoOrMoreUtf8Bytes - threeOrMoreUtf8Bytes);
326+
Vector<nuint> sumVector = (Vector<nuint>)(Vector<ushort>.Zero - twoOrMoreUtf8Bytes - threeOrMoreUtf8Bytes);
345327

346328
// We'll try summing by a natural word (rather than a 16-bit word) at a time,
347329
// which should halve the number of operations we must perform.
348330

349331
nuint popcnt = 0;
350-
for (int i = 0; i < Vector<nuint_t>.Count; i++)
332+
for (int i = 0; i < Vector<nuint>.Count; i++)
351333
{
352334
popcnt += (nuint)sumVector[i];
353335
}

0 commit comments

Comments
 (0)