Skip to content

Commit e68e7d9

Browse files
committed
Make desiredStartIndex an int
1 parent 3bd81c1 commit e68e7d9

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/libraries/System.Private.CoreLib/src/System/Memory.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -327,12 +327,12 @@ public Span<T> Span
327327
// least to be in-bounds when compared with the original Memory<T> instance, so using the span won't
328328
// AV the process.
329329

330-
nuint desiredStartIndex = (uint)_index & (uint)ReadOnlyMemory<T>.RemoveFlagsBitMask;
330+
int desiredStartIndex = _index & ReadOnlyMemory<T>.RemoveFlagsBitMask;
331331
int desiredLength = _length;
332332

333333
#if TARGET_64BIT
334334
// See comment in Span<T>.Slice for how this works.
335-
if ((ulong)desiredStartIndex + (ulong)(uint)desiredLength > (ulong)(uint)lengthOfUnderlyingSpan)
335+
if ((ulong)(uint)desiredStartIndex + (ulong)(uint)desiredLength > (ulong)(uint)lengthOfUnderlyingSpan)
336336
{
337337
ThrowHelper.ThrowArgumentOutOfRangeException();
338338
}
@@ -343,7 +343,7 @@ public Span<T> Span
343343
}
344344
#endif
345345

346-
refToReturn = ref Unsafe.Add(ref refToReturn, (nint)desiredStartIndex);
346+
refToReturn = ref Unsafe.Add(ref refToReturn, (uint)desiredStartIndex);
347347
lengthOfUnderlyingSpan = desiredLength;
348348
}
349349

src/libraries/System.Private.CoreLib/src/System/ReadOnlyMemory.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,12 +249,12 @@ public ReadOnlySpan<T> Span
249249
// least to be in-bounds when compared with the original Memory<T> instance, so using the span won't
250250
// AV the process.
251251

252-
nuint desiredStartIndex = (uint)_index & (uint)RemoveFlagsBitMask;
252+
int desiredStartIndex = _index & RemoveFlagsBitMask;
253253
int desiredLength = _length;
254254

255255
#if TARGET_64BIT
256256
// See comment in Span<T>.Slice for how this works.
257-
if ((ulong)desiredStartIndex + (ulong)(uint)desiredLength > (ulong)(uint)lengthOfUnderlyingSpan)
257+
if ((ulong)(uint)desiredStartIndex + (ulong)(uint)desiredLength > (ulong)(uint)lengthOfUnderlyingSpan)
258258
{
259259
ThrowHelper.ThrowArgumentOutOfRangeException();
260260
}
@@ -265,7 +265,7 @@ public ReadOnlySpan<T> Span
265265
}
266266
#endif
267267

268-
refToReturn = ref Unsafe.Add(ref refToReturn, (nint)desiredStartIndex);
268+
refToReturn = ref Unsafe.Add(ref refToReturn, (uint)desiredStartIndex);
269269
lengthOfUnderlyingSpan = desiredLength;
270270
}
271271

0 commit comments

Comments
 (0)