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
// 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===================================