Skip to content
Snippets Groups Projects
Commit 9b64a778 authored by dgelessus's avatar dgelessus
Browse files

Avoid unnecessary list access in generated checkResult calls

parent 26500676
Branches
Tags
No related merge requests found
...@@ -130,13 +130,18 @@ public class GenerateAlternativeCodeForParser extends DepthFirstAdapter ...@@ -130,13 +130,18 @@ public class GenerateAlternativeCodeForParser extends DepthFirstAdapter
{ {
try try
{ {
PTerm firstTerm = null;
for(PTerm term : node.getTerms()) for(PTerm term : node.getTerms())
{ {
if(firstTerm == null)
{
firstTerm = term;
}
macros.apply(file, "ParserNewBodyListAdd", new String[] {getVariableName(term)}); macros.apply(file, "ParserNewBodyListAdd", new String[] {getVariableName(term)});
} }
if (popCount > 0) { if (firstTerm != null && popCount > 0) {
// The nodeArrayList variables are numbered starting at 1, so the first popped variable has the number popCount and not popCount-1. // The nodeArrayList variables are numbered starting at 1, so the first popped variable has the number popCount and not popCount-1.
macros.apply(file, "ParserNewCheck", new String[] {String.valueOf(popCount)}); macros.apply(file, "ParserNewCheck", new String[] {getVariableName(firstTerm), String.valueOf(popCount)});
} }
macros.apply(file, "ParserNewTail"); macros.apply(file, "ParserNewTail");
} }
......
This diff is collapsed.
...@@ -396,7 +396,7 @@ Macro:ParserNewBodyListAdd ...@@ -396,7 +396,7 @@ Macro:ParserNewBodyListAdd
$ $
Macro:ParserNewCheck Macro:ParserNewCheck
checkResult(nodeList.get(0), nodeArrayList1, nodeArrayList$0$); checkResult($0$, nodeArrayList1, nodeArrayList$1$);
$ $
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment