Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use actual nint/nuint in Latin1Utility #44162

Merged
merged 1 commit into from
Nov 3, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,10 @@
using System.Runtime.Intrinsics.X86;
using Internal.Runtime.CompilerServices;

#pragma warning disable SA1121 // explicitly using type aliases instead of built-in types
#if TARGET_64BIT
using nint = System.Int64;
using nuint = System.UInt64;
#else // TARGET_64BIT
using nint = System.Int32;
using nuint = System.UInt32;
#endif // TARGET_64BIT

namespace System.Text
{
internal static partial class Latin1Utility
{
#if DEBUG
static Latin1Utility()
{
Debug.Assert(sizeof(nint) == IntPtr.Size && nint.MinValue < 0, "nint is defined incorrectly.");
Debug.Assert(sizeof(nuint) == IntPtr.Size && nuint.MinValue == 0, "nuint is defined incorrectly.");
}
#endif // DEBUG

/// <summary>
/// Returns the index in <paramref name="pBuffer"/> where the first non-Latin1 char is found.
/// Returns <paramref name="bufferLength"/> if the buffer is empty or all-Latin1.
Expand Down Expand Up @@ -776,7 +759,7 @@ private static unsafe nuint NarrowUtf16ToLatin1_Sse2(char* pUtf16Buffer, byte* p
// JIT turns the below into constants

uint SizeOfVector128 = (uint)Unsafe.SizeOf<Vector128<byte>>();
nuint MaskOfAllBitsInVector128 = (nuint)(SizeOfVector128 - 1);
nuint MaskOfAllBitsInVector128 = SizeOfVector128 - 1;

// This method is written such that control generally flows top-to-bottom, avoiding
// jumps as much as possible in the optimistic case of "all Latin-1". If we see non-Latin-1
Expand Down Expand Up @@ -963,7 +946,7 @@ private static unsafe void WidenLatin1ToUtf16_Sse2(byte* pLatin1Buffer, char* pU
// JIT turns the below into constants

uint SizeOfVector128 = (uint)Unsafe.SizeOf<Vector128<byte>>();
nuint MaskOfAllBitsInVector128 = (nuint)(SizeOfVector128 - 1);
nuint MaskOfAllBitsInVector128 = SizeOfVector128 - 1;

Debug.Assert(Sse2.IsSupported);
Debug.Assert(BitConverter.IsLittleEndian);
Expand Down