Skip to content

Commit e2f5aa4

Browse files
committed
Avoid unnecessary ToLower call if the token is too long
1 parent 029f124 commit e2f5aa4

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

SimpleJSON.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -523,11 +523,14 @@ private static JSONNode ParseElement(string token, bool quoted)
523523
{
524524
if (quoted)
525525
return token;
526-
string tmp = token.ToLower();
527-
if (tmp == "false" || tmp == "true")
528-
return tmp == "true";
529-
if (tmp == "null")
530-
return JSONNull.CreateOrGet();
526+
if (token.Length <= 5)
527+
{
528+
string tmp = token.ToLower();
529+
if (tmp == "false" || tmp == "true")
530+
return tmp == "true";
531+
if (tmp == "null")
532+
return JSONNull.CreateOrGet();
533+
}
531534
double val;
532535
if (double.TryParse(token, NumberStyles.Float, CultureInfo.InvariantCulture, out val))
533536
return val;

0 commit comments

Comments
 (0)