Skip to content

Commit

Permalink
Revert string changes
Browse files Browse the repository at this point in the history
  • Loading branch information
nathan-moore committed Aug 28, 2020
1 parent ee54472 commit 6f77bf8
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/libraries/System.Private.CoreLib/src/System/String.cs
Original file line number Diff line number Diff line change
Expand Up @@ -487,9 +487,13 @@ public char[] ToCharArray(int startIndex, int length)
[NonVersionable]
public static bool IsNullOrEmpty([NotNullWhen(false)] string? value)
{
// Using 0u >= (uint)value.Length rather than
// value.Length == 0 as it will elide the bounds check to
// the first char: value[0] if that is performed following the test
// for the same test cost.
// Ternary operator returning true/false prevents redundant asm generation:
// https://github.com/dotnet/runtime/issues/4207
return (value == null || 0 == value.Length) ? true : false;
return (value == null || 0u >= (uint)value.Length) ? true : false;
}

public static bool IsNullOrWhiteSpace([NotNullWhen(false)] string? value)
Expand Down Expand Up @@ -607,7 +611,6 @@ public StringRuneEnumerator EnumerateRunes()
internal static unsafe int wcslen(char* ptr)
{
// IndexOf processes memory in aligned chunks, and thus it won't crash even if it accesses memory beyond the null terminator.
// This IndexOf behavior is an implementation detail of the runtime and callers outside System.Private.CoreLib must not depend on it.
int length = SpanHelpers.IndexOf(ref *ptr, '\0', int.MaxValue);
if (length < 0)
{
Expand All @@ -621,7 +624,6 @@ internal static unsafe int wcslen(char* ptr)
internal static unsafe int strlen(byte* ptr)
{
// IndexOf processes memory in aligned chunks, and thus it won't crash even if it accesses memory beyond the null terminator.
// This IndexOf behavior is an implementation detail of the runtime and callers outside System.Private.CoreLib must not depend on it.
int length = SpanHelpers.IndexOf(ref *ptr, (byte)'\0', int.MaxValue);
if (length < 0)
{
Expand Down

0 comments on commit 6f77bf8

Please sign in to comment.