Skip to content

Commit

Permalink
Remove isField argument
Browse files Browse the repository at this point in the history
  • Loading branch information
mtschoen committed Jan 16, 2022
1 parent a567430 commit a0c2d75
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions JSONObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ static bool BeginParse(string inputString, int offset, ref int endOffset, JSONOb
// ReSharper restore UseNameofExpression

static void Parse(string inputString, ref int offset, int endOffset, JSONObject container, int maxDepth,
bool storeExcessLevels, int depth = 0, bool isField = false, bool isRoot = true) {
bool storeExcessLevels, int depth = 0, bool isRoot = true) {
if (!BeginParse(inputString, offset, ref endOffset, container, maxDepth, storeExcessLevels))
return;

Expand Down Expand Up @@ -552,8 +552,7 @@ static void Parse(string inputString, ref int offset, int endOffset, JSONObject
}

newContainer.type = Type.Object;
isField = true;
Parse(inputString, ref offset, endOffset, newContainer, maxDepth, storeExcessLevels, depth + 1, isField, false);
Parse(inputString, ref offset, endOffset, newContainer, maxDepth, storeExcessLevels, depth + 1, false);

break;
case '[':
Expand All @@ -572,7 +571,7 @@ static void Parse(string inputString, ref int offset, int endOffset, JSONObject
}

newContainer.type = Type.Array;
Parse(inputString, ref offset, endOffset, newContainer, maxDepth, storeExcessLevels, depth + 1, isField, false);
Parse(inputString, ref offset, endOffset, newContainer, maxDepth, storeExcessLevels, depth + 1, false);

break;
case '}':
Expand All @@ -589,7 +588,7 @@ static void Parse(string inputString, ref int offset, int endOffset, JSONObject
ParseQuote(ref openQuote, offset, ref quoteStart, ref quoteEnd);
break;
case ':':
if (!ParseColon(inputString, openQuote, ref isField, container, ref startOffset, offset, quoteStart, quoteEnd, bakeDepth))
if (!ParseColon(inputString, openQuote, container, ref startOffset, offset, quoteStart, quoteEnd, bakeDepth))
return;

break;
Expand All @@ -605,7 +604,7 @@ static void Parse(string inputString, ref int offset, int endOffset, JSONObject
}

static IEnumerable<ParseResult> ParseAsync(string inputString, int offset, int endOffset, JSONObject container,
int maxDepth, bool storeExcessLevels, int depth = 0, bool isField = false, bool isRoot = true) {
int maxDepth, bool storeExcessLevels, int depth = 0, bool isRoot = true) {
if (!BeginParse(inputString, offset, ref endOffset, container, maxDepth, storeExcessLevels))
yield break;

Expand Down Expand Up @@ -635,7 +634,6 @@ static IEnumerable<ParseResult> ParseAsync(string inputString, int offset, int e
if (openQuote)
break;

isField = false;
if (maxDepth >= 0 && depth >= maxDepth) {
bakeDepth++;
break;
Expand All @@ -648,8 +646,7 @@ static IEnumerable<ParseResult> ParseAsync(string inputString, int offset, int e
}

newContainer.type = Type.Object;
isField = true;
foreach (var e in ParseAsync(inputString, offset, endOffset, newContainer, maxDepth, storeExcessLevels, depth + 1, isField, false)) {
foreach (var e in ParseAsync(inputString, offset, endOffset, newContainer, maxDepth, storeExcessLevels, depth + 1, false)) {
if (e.pause)
yield return e;

Expand All @@ -673,7 +670,7 @@ static IEnumerable<ParseResult> ParseAsync(string inputString, int offset, int e
}

newContainer.type = Type.Array;
foreach (var e in ParseAsync(inputString, offset, endOffset, newContainer, maxDepth, storeExcessLevels, depth + 1, isField, false)) {
foreach (var e in ParseAsync(inputString, offset, endOffset, newContainer, maxDepth, storeExcessLevels, depth + 1, false)) {
if (e.pause)
yield return e;

Expand All @@ -699,7 +696,7 @@ static IEnumerable<ParseResult> ParseAsync(string inputString, int offset, int e
ParseQuote(ref openQuote, offset, ref quoteStart, ref quoteEnd);
break;
case ':':
if (!ParseColon(inputString, openQuote, ref isField, container, ref startOffset, offset, quoteStart, quoteEnd, bakeDepth)) {
if (!ParseColon(inputString, openQuote, container, ref startOffset, offset, quoteStart, quoteEnd, bakeDepth)) {
yield return new ParseResult(container, offset, false);
yield break;
}
Expand Down Expand Up @@ -887,7 +884,7 @@ static void ParseQuote(ref bool openQuote, int offset, ref int quoteStart, ref i
}
}

static bool ParseColon(string inputString, bool openQuote, ref bool isField, JSONObject container,
static bool ParseColon(string inputString, bool openQuote, JSONObject container,
ref int startOffset,int offset, int quoteStart, int quoteEnd, int bakeDepth) {
if (openQuote || bakeDepth > 0)
return true;
Expand All @@ -905,7 +902,6 @@ static bool ParseColon(string inputString, bool openQuote, ref bool isField, JSO

container.keys.Add(inputString.Substring(quoteStart, quoteEnd - quoteStart));
startOffset = offset;
isField = false;

return true;
}
Expand Down

0 comments on commit a0c2d75

Please sign in to comment.