Small cleanup to Char.IsWhiteSpaceLatin1
authorStephen Toub <stoub@microsoft.com>
Thu, 15 Jun 2017 20:14:32 +0000 (16:14 -0400)
committerStephen Toub <stoub@microsoft.com>
Thu, 15 Jun 2017 20:14:32 +0000 (16:14 -0400)
For some reason this is resulting in measurably better throughput, in particular for non-whitespace chars, so much so that it's visible in microbenchmarks against string.IsNullOrWhiteSpace.

If nothing else, it's cleaner.

Commit migrated from https://github.com/dotnet/coreclr/commit/2f05efea2ea9e9c9e1ee9772a9da5fae4ca76ad7

src/coreclr/src/mscorlib/shared/System/Char.cs

index 7244176..a5a3f7b 100644 (file)
@@ -274,11 +274,7 @@ namespace System
             // U+000d = <control> CARRIAGE RETURN
             // U+0085 = <control> NEXT LINE
             // U+00a0 = NO-BREAK SPACE
-            if ((c == ' ') || (c >= '\x0009' && c <= '\x000d') || c == '\x00a0' || c == '\x0085')
-            {
-                return (true);
-            }
-            return (false);
+            return c == ' ' || (c >= '\x0009' && c <= '\x000d') || c == '\x00a0' || c == '\x0085';
         }
 
         /*===============================ISWHITESPACE===================================