Skip to content

Commit d34eb61

Browse files
authored
Remove a few uint casts in CoreLib (#119973)
1 parent 2a9066e commit d34eb61

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/MemoryMarshal.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ public static unsafe T Read<T>(ReadOnlySpan<byte> source)
472472
{
473473
ThrowHelper.ThrowArgument_TypeContainsReferences(typeof(T));
474474
}
475-
if (sizeof(T) > source.Length)
475+
if (source.Length < sizeof(T))
476476
{
477477
ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.length);
478478
}
@@ -491,7 +491,7 @@ public static unsafe bool TryRead<T>(ReadOnlySpan<byte> source, out T value)
491491
{
492492
ThrowHelper.ThrowArgument_TypeContainsReferences(typeof(T));
493493
}
494-
if (sizeof(T) > (uint)source.Length)
494+
if (source.Length < sizeof(T))
495495
{
496496
value = default;
497497
return false;
@@ -511,7 +511,7 @@ public static unsafe void Write<T>(Span<byte> destination, in T value)
511511
{
512512
ThrowHelper.ThrowArgument_TypeContainsReferences(typeof(T));
513513
}
514-
if ((uint)sizeof(T) > (uint)destination.Length)
514+
if (destination.Length < sizeof(T))
515515
{
516516
ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.length);
517517
}
@@ -530,7 +530,7 @@ public static unsafe bool TryWrite<T>(Span<byte> destination, in T value)
530530
{
531531
ThrowHelper.ThrowArgument_TypeContainsReferences(typeof(T));
532532
}
533-
if (sizeof(T) > (uint)destination.Length)
533+
if (destination.Length < sizeof(T))
534534
{
535535
return false;
536536
}
@@ -553,7 +553,7 @@ public static unsafe ref T AsRef<T>(Span<byte> span)
553553
{
554554
ThrowHelper.ThrowArgument_TypeContainsReferences(typeof(T));
555555
}
556-
if (sizeof(T) > (uint)span.Length)
556+
if (span.Length < sizeof(T))
557557
{
558558
ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.length);
559559
}
@@ -575,7 +575,7 @@ public static unsafe ref readonly T AsRef<T>(ReadOnlySpan<byte> span)
575575
{
576576
ThrowHelper.ThrowArgument_TypeContainsReferences(typeof(T));
577577
}
578-
if (sizeof(T) > (uint)span.Length)
578+
if (span.Length < sizeof(T))
579579
{
580580
ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.length);
581581
}

src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector512.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,7 @@ public static void CopyTo<T>(this Vector512<T> vector, T[] destination, int star
715715
/// <exception cref="NotSupportedException">The type of <paramref name="vector" /> and <paramref name="destination" /> (<typeparamref name="T" />) is not supported.</exception>
716716
public static void CopyTo<T>(this Vector512<T> vector, Span<T> destination)
717717
{
718-
if ((uint)destination.Length < (uint)Vector512<T>.Count)
718+
if (destination.Length < Vector512<T>.Count)
719719
{
720720
ThrowHelper.ThrowArgumentException_DestinationTooShort();
721721
}
@@ -4045,7 +4045,7 @@ internal static Vector512<T> Truncate<T>(Vector512<T> vector)
40454045
/// <exception cref="NotSupportedException">The type of <paramref name="vector" /> and <paramref name="destination" /> (<typeparamref name="T" />) is not supported.</exception>
40464046
public static bool TryCopyTo<T>(this Vector512<T> vector, Span<T> destination)
40474047
{
4048-
if ((uint)destination.Length < (uint)Vector512<T>.Count)
4048+
if (destination.Length < Vector512<T>.Count)
40494049
{
40504050
return false;
40514051
}

0 commit comments

Comments
 (0)