-Refactored ToCamelCase

This commit is contained in:
James Newton-King
2016-03-04 21:31:36 +13:00
parent 82b95da77a
commit f5fbd6fd3c
+11 -11
View File
@@ -177,19 +177,19 @@ namespace Newtonsoft.Json.Utilities
char[] chars = s.ToCharArray(); char[] chars = s.ToCharArray();
int toLowerUntilIndex = 1; for (int i = 0; i < chars.Length; i++)
while (toLowerUntilIndex < chars.Length && char.IsUpper(chars[toLowerUntilIndex]))
{ {
++toLowerUntilIndex; if (i == 1 && !char.IsUpper(chars[i]))
} {
// decrement if starts with consecutive upper case letters but is not all upper break;
if (toLowerUntilIndex > 1 && toLowerUntilIndex < chars.Length) }
{
--toLowerUntilIndex; bool hasNext = (i + 1 < chars.Length);
} if (i > 0 && hasNext && !char.IsUpper(chars[i + 1]))
{
break;
}
for (int i = 0; i < toLowerUntilIndex; ++i)
{
#if !(DOTNET || PORTABLE) #if !(DOTNET || PORTABLE)
chars[i] = char.ToLower(chars[i], CultureInfo.InvariantCulture); chars[i] = char.ToLower(chars[i], CultureInfo.InvariantCulture);
#else #else