summaryrefslogtreecommitdiff
path: root/src/mscorlib/shared/System/String.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/mscorlib/shared/System/String.cs')
-rw-r--r--src/mscorlib/shared/System/String.cs8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/mscorlib/shared/System/String.cs b/src/mscorlib/shared/System/String.cs
index 42d21ba068..9d230fe3dc 100644
--- a/src/mscorlib/shared/System/String.cs
+++ b/src/mscorlib/shared/System/String.cs
@@ -438,7 +438,13 @@ namespace System
[NonVersionable]
public static bool IsNullOrEmpty(string value)
{
- return (value == null || value.Length == 0);
+ // 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/coreclr/issues/914
+ return (value == null || 0u >= (uint)value.Length) ? true : false;
}
public static bool IsNullOrWhiteSpace(string value)