Skip to content

Commit

Permalink
Optimize ParseArray and ParseObject that remove redundant variable as…
Browse files Browse the repository at this point in the history
…signment.

Optimize DebutTool Assert call.
  • Loading branch information
scottcgi committed Feb 5, 2018
1 parent 3c7cf13 commit a8d8531
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions MojoUnityJson.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
*
* Since : 2017-9-6
* Author : scott.cgi
* Version: 1.1.5
* Update : 2018-1-25
* Version: 1.1.8
* Update : 2018-2-5
------------------------------------------------------------------------------------------------------------------------
*/

Expand Down Expand Up @@ -43,9 +43,8 @@ public static JsonValue Parse(string json)
private static JsonValue ParseValue(Data data)
{
SkipWhiteSpace(data);
var c = data.json[data.index];

switch (c)
switch (data.json[data.index])
{
case '{':
return ParseObject(data);
Expand Down Expand Up @@ -110,7 +109,15 @@ private static JsonValue ParseValue(Data data)
break;
}

throw new Exception(string.Format("Json ParseValue error on char '{0}' index in '{1}' ", c, data.index));
throw new Exception
(
string.Format
(
"Json ParseValue error on char '{0}' index at '{1}' ",
data.json[data.index],
data.index
)
);
}


Expand Down Expand Up @@ -147,9 +154,7 @@ private static JsonValue ParseObject(Data data)

while (true)
{
var c = data.json[data.index++];

switch (c)
switch (data.json[data.index++])
{
// check end '"'
case '"':
Expand Down Expand Up @@ -198,10 +203,9 @@ private static JsonValue ParseObject(Data data)
DebugTool.Assert
(
data.json[data.index] == '}',
"Json ParseObject error, after key = {0}, char '{1}' should be '{2}' ",
"Json ParseObject error, after key = {0}, char '{1}' should be '}' ",
key,
data.json[data.index],
'}'
data.json[data.index]
);

break;
Expand Down

0 comments on commit a8d8531

Please sign in to comment.