Skip to content

Commit

Permalink
Minor optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
cwensley committed Oct 3, 2013
1 parent 02bc71d commit 3c1309e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 9 deletions.
7 changes: 2 additions & 5 deletions Eto.Parse/Parsers/LiteralTerminal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public LiteralTerminal()

public LiteralTerminal(string value)
{
value.ThrowIfNull("value", "Value must not be null");
Value = value;
}

Expand All @@ -38,11 +39,7 @@ public override void Initialize(ParserInitializeArgs args)

protected override int InnerParse(ParseArgs args)
{
if (Value != null)
{
return !args.Scanner.ReadString(Value, caseSensitive) ? -1 : Value.Length;
}
return 0;
return !args.Scanner.ReadString(Value, caseSensitive) ? -1 : Value.Length;
}

public override Parser Clone(ParserCloneArgs args)
Expand Down
2 changes: 1 addition & 1 deletion Eto.Parse/Parsers/RepeatCharTerminal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ protected override int InnerParse(ParseArgs args)
var count = 0;
while (ch != -1 && item.Test((char)ch))
{
length++;
count++;
ch = scanner.ReadChar();
if (count >= item.Maximum)
Expand All @@ -94,6 +93,7 @@ protected override int InnerParse(ParseArgs args)
scanner.Position = pos;
return -1;
}
length += count;
}
scanner.Position = pos + length;
return length;
Expand Down
4 changes: 1 addition & 3 deletions Eto.Parse/Parsers/SequenceParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@ protected override int InnerParse(ParseArgs args)
childMatch = parser.Parse(args);
if (childMatch >= 0)
{
if (childMatch > 0)
length += sepMatch;
length += childMatch;
length += childMatch + sepMatch;
continue;
}
}
Expand Down

0 comments on commit 3c1309e

Please sign in to comment.