From 3ce59b1ab67fcf7c23c9fbc5da9b229f54568414 Mon Sep 17 00:00:00 2001 From: Ahson Khan Date: Thu, 23 Aug 2018 19:11:48 -0700 Subject: [PATCH] Workaround to remove unnecessary bounds checks when using {ReadOnly}Span.IsEmpty (#19640) --- src/System.Private.CoreLib/shared/System/ReadOnlySpan.cs | 3 ++- src/System.Private.CoreLib/shared/System/Span.cs | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/System.Private.CoreLib/shared/System/ReadOnlySpan.cs b/src/System.Private.CoreLib/shared/System/ReadOnlySpan.cs index 61af717..17b7134 100644 --- a/src/System.Private.CoreLib/shared/System/ReadOnlySpan.cs +++ b/src/System.Private.CoreLib/shared/System/ReadOnlySpan.cs @@ -40,7 +40,8 @@ namespace System [NonVersionable] get { - return _length == 0; + // Workaround for https://github.com/dotnet/coreclr/issues/19620 + return 0 >= (uint)_length; } } /// diff --git a/src/System.Private.CoreLib/shared/System/Span.cs b/src/System.Private.CoreLib/shared/System/Span.cs index ddbdba1..185042f 100644 --- a/src/System.Private.CoreLib/shared/System/Span.cs +++ b/src/System.Private.CoreLib/shared/System/Span.cs @@ -40,7 +40,8 @@ namespace System [NonVersionable] get { - return _length == 0; + // Workaround for https://github.com/dotnet/coreclr/issues/19620 + return 0 >= (uint)_length; } } -- 2.7.4