From f99876dd2443ce92ed417ec95e35a1e113f6dbed Mon Sep 17 00:00:00 2001 From: stephentoub Date: Sat, 6 Feb 2016 10:04:43 -0500 Subject: [PATCH] Tweak Enum.TryParse whitespace skipping slightly As a simple addendum to my previous Enum.TryParse change, if the string begins with whitespace, we already know where the whitespace ends, so we don't need to retraverse it. --- src/mscorlib/src/System/Enum.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mscorlib/src/System/Enum.cs b/src/mscorlib/src/System/Enum.cs index fa674e74cf12..b0e3bf8f07e9 100644 --- a/src/mscorlib/src/System/Enum.cs +++ b/src/mscorlib/src/System/Enum.cs @@ -428,7 +428,7 @@ private static bool TryParseEnum(Type enumType, String value, bool ignoreCase, r StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal; - int valueIndex = 0; + int valueIndex = firstNonWhitespaceIndex; while (valueIndex <= value.Length) // '=' is to handle invalid case of an ending comma { // Find the next separator, if there is one, otherwise the end of the string.