Skip to content

Commit

Permalink
Remove IsEmpty workaround in Span and ReadOnlySpan (dotnet#66865)
Browse files Browse the repository at this point in the history
* Revert "Workaround to remove unnecessary bounds checks when using {ReadOnly}Span.IsEmpty (dotnet/coreclr#19640)"

This reverts commit 82bd67f.

* Update doc comments

* Apply suggestions from code review

Co-authored-by: Robin Lindner <[email protected]>

* Apply suggestions from code review

Co-authored-by: Robin Lindner <[email protected]>

Co-authored-by: Aaron Robinson <[email protected]>
Co-authored-by: Robin Lindner <[email protected]>
Co-authored-by: Robin Lindner <[email protected]>
  • Loading branch information
4 people authored Mar 29, 2022
1 parent d96073a commit 1e2485f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,13 @@ public int Length
}

/// <summary>
/// Returns true if Length is 0.
/// Gets a value indicating whether this <see cref="ReadOnlySpan{T}"/> is empty.
/// </summary>
/// <value><see langword="true"/> if this span is empty; otherwise, <see langword="false"/>.</value>
public bool IsEmpty
{
[NonVersionable]
get => 0 >= (uint)_length; // Workaround for https://github.com/dotnet/runtime/issues/10950
get => _length == 0;
}

/// <summary>
Expand Down
5 changes: 3 additions & 2 deletions src/libraries/System.Private.CoreLib/src/System/Span.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,13 @@ public int Length
}

/// <summary>
/// Returns true if Length is 0.
/// Gets a value indicating whether this <see cref="Span{T}"/> is empty.
/// </summary>
/// <value><see langword="true"/> if this span is empty; otherwise, <see langword="false"/>.</value>
public bool IsEmpty
{
[NonVersionable]
get => 0 >= (uint)_length; // Workaround for https://github.com/dotnet/runtime/issues/10950
get => _length == 0;
}

/// <summary>
Expand Down

0 comments on commit 1e2485f

Please sign in to comment.