Workaround to remove unnecessary bounds checks when using {ReadOnly}Span.IsEmpty...
authorAhson Khan <ahkha@microsoft.com>
Fri, 24 Aug 2018 02:11:48 +0000 (19:11 -0700)
committerGitHub <noreply@github.com>
Fri, 24 Aug 2018 02:11:48 +0000 (19:11 -0700)
src/System.Private.CoreLib/shared/System/ReadOnlySpan.cs
src/System.Private.CoreLib/shared/System/Span.cs

index 61af717..17b7134 100644 (file)
@@ -40,7 +40,8 @@ namespace System
             [NonVersionable]
             get
             {
-                return _length == 0;
+                // Workaround for https://github.com/dotnet/coreclr/issues/19620
+                return 0 >= (uint)_length;
             }
         }
         /// <summary>
index ddbdba1..185042f 100644 (file)
@@ -40,7 +40,8 @@ namespace System
             [NonVersionable]
             get
             {
-                return _length == 0;
+                // Workaround for https://github.com/dotnet/coreclr/issues/19620
+                return 0 >= (uint)_length;
             }
         }