HHH-5843 - Avoid useless branches during HQL parsing when trace logging is disabled

This commit is contained in:
Sanne Grinovero 2011-01-14 16:31:01 +00:00 committed by JPAV
parent 19bc3ba7fc
commit 2641842ba9
145 changed files with 12 additions and 7 deletions

View File

@ -75,9 +75,9 @@ public final class HqlParser extends HqlBaseParser {
private int traceDepth = 0; private int traceDepth = 0;
@Override @Override
public void traceIn(String ruleName) { public void traceIn(String ruleName) {
if (!LOG.isTraceEnabled()) return;
if (inputState.guessing > 0) return; if (inputState.guessing > 0) return;
String prefix = StringHelper.repeat( '-', (traceDepth++ * 2) ) + "-> "; String prefix = StringHelper.repeat( '-', (traceDepth++ * 2) ) + "-> ";
LOG.trace(prefix + ruleName); LOG.trace(prefix + ruleName);
@ -85,6 +85,7 @@ public final class HqlParser extends HqlBaseParser {
@Override @Override
public void traceOut(String ruleName) { public void traceOut(String ruleName) {
if (!LOG.isTraceEnabled()) return;
if (inputState.guessing > 0) return; if (inputState.guessing > 0) return;
String prefix = "<-" + StringHelper.repeat( '-', (--traceDepth * 2) ) + " "; String prefix = "<-" + StringHelper.repeat( '-', (--traceDepth * 2) ) + " ";
LOG.trace(prefix + ruleName); LOG.trace(prefix + ruleName);

View File

@ -107,7 +107,7 @@ import antlr.collections.AST;
* Implements methods used by the HQL->SQL tree transform grammar (a.k.a. the second phase). * Implements methods used by the HQL->SQL tree transform grammar (a.k.a. the second phase).
* <ul> * <ul>
* <li>Isolates the Hibernate API-specific code from the ANTLR generated code.</li> * <li>Isolates the Hibernate API-specific code from the ANTLR generated code.</li>
* <li>Handles the SQL framgents generated by the persisters in order to create the SELECT and FROM clauses, * <li>Handles the SQL fragments generated by the persisters in order to create the SELECT and FROM clauses,
* taking into account the joins and projections that are implied by the mappings (persister/queryable).</li> * taking into account the joins and projections that are implied by the mappings (persister/queryable).</li>
* <li>Uses SqlASTFactory to create customized AST nodes.</li> * <li>Uses SqlASTFactory to create customized AST nodes.</li>
* </ul> * </ul>
@ -185,6 +185,7 @@ public class HqlSqlWalker extends HqlSqlBaseWalker implements ErrorReporter, Par
@Override @Override
public void traceIn(String ruleName, AST tree) { public void traceIn(String ruleName, AST tree) {
if (!LOG.isTraceEnabled()) return;
if (inputState.guessing > 0) return; if (inputState.guessing > 0) return;
String prefix = StringHelper.repeat( '-', (traceDepth++ * 2) ) + "-> "; String prefix = StringHelper.repeat( '-', (traceDepth++ * 2) ) + "-> ";
String traceText = ruleName + " (" + buildTraceNodeName(tree) + ")"; String traceText = ruleName + " (" + buildTraceNodeName(tree) + ")";
@ -199,6 +200,7 @@ public class HqlSqlWalker extends HqlSqlBaseWalker implements ErrorReporter, Par
@Override @Override
public void traceOut(String ruleName, AST tree) { public void traceOut(String ruleName, AST tree) {
if (!LOG.isTraceEnabled()) return;
if (inputState.guessing > 0) return; if (inputState.guessing > 0) return;
String prefix = "<-" + StringHelper.repeat( '-', (--traceDepth * 2) ) + " "; String prefix = "<-" + StringHelper.repeat( '-', (--traceDepth * 2) ) + " ";
LOG.trace(prefix + ruleName); LOG.trace(prefix + ruleName);

View File

@ -61,9 +61,9 @@ public class SqlGenerator extends SqlGeneratorBase implements ErrorReporter {
/** /**
* all append invocations on the buf should go through this Output instance variable. * all append invocations on the buf should go through this Output instance variable.
* The value of this variable may be temporarily substitued by sql function processing code * The value of this variable may be temporarily substituted by sql function processing code
* to catch generated arguments. * to catch generated arguments.
* This is because sql function templates need arguments as seperate string chunks * This is because sql function templates need arguments as separate string chunks
* that will be assembled into the target dialect-specific function call. * that will be assembled into the target dialect-specific function call.
*/ */
private SqlWriter writer = new DefaultWriter(); private SqlWriter writer = new DefaultWriter();
@ -81,6 +81,7 @@ public class SqlGenerator extends SqlGeneratorBase implements ErrorReporter {
@Override @Override
public void traceIn(String ruleName, AST tree) { public void traceIn(String ruleName, AST tree) {
if (!LOG.isTraceEnabled()) return;
if (inputState.guessing > 0) return; if (inputState.guessing > 0) return;
String prefix = StringHelper.repeat( '-', (traceDepth++ * 2) ) + "-> "; String prefix = StringHelper.repeat( '-', (traceDepth++ * 2) ) + "-> ";
String traceText = ruleName + " (" + buildTraceNodeName(tree) + ")"; String traceText = ruleName + " (" + buildTraceNodeName(tree) + ")";
@ -95,6 +96,7 @@ public class SqlGenerator extends SqlGeneratorBase implements ErrorReporter {
@Override @Override
public void traceOut(String ruleName, AST tree) { public void traceOut(String ruleName, AST tree) {
if (!LOG.isTraceEnabled()) return;
if (inputState.guessing > 0) return; if (inputState.guessing > 0) return;
String prefix = "<-" + StringHelper.repeat( '-', (--traceDepth * 2) ) + " "; String prefix = "<-" + StringHelper.repeat( '-', (--traceDepth * 2) ) + " ";
LOG.trace(prefix + ruleName); LOG.trace(prefix + ruleName);

Some files were not shown because too many files have changed in this diff Show More