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

@ -73,11 +73,11 @@ public final class HqlParser extends HqlBaseParser {
// handle trace logging ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
private int traceDepth = 0;
private int traceDepth = 0;
@Override
public void traceIn(String ruleName) {
if (!LOG.isTraceEnabled()) return;
if (inputState.guessing > 0) return;
String prefix = StringHelper.repeat( '-', (traceDepth++ * 2) ) + "-> ";
LOG.trace(prefix + ruleName);
@ -85,6 +85,7 @@ public final class HqlParser extends HqlBaseParser {
@Override
public void traceOut(String ruleName) {
if (!LOG.isTraceEnabled()) return;
if (inputState.guessing > 0) return;
String prefix = "<-" + StringHelper.repeat( '-', (--traceDepth * 2) ) + " ";
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).
* <ul>
* <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>
* <li>Uses SqlASTFactory to create customized AST nodes.</li>
* </ul>
@ -181,10 +181,11 @@ public class HqlSqlWalker extends HqlSqlBaseWalker implements ErrorReporter, Par
// handle trace logging ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
private int traceDepth = 0;
private int traceDepth = 0;
@Override
public void traceIn(String ruleName, AST tree) {
if (!LOG.isTraceEnabled()) return;
if (inputState.guessing > 0) return;
String prefix = StringHelper.repeat( '-', (traceDepth++ * 2) ) + "-> ";
String traceText = ruleName + " (" + buildTraceNodeName(tree) + ")";
@ -199,6 +200,7 @@ public class HqlSqlWalker extends HqlSqlBaseWalker implements ErrorReporter, Par
@Override
public void traceOut(String ruleName, AST tree) {
if (!LOG.isTraceEnabled()) return;
if (inputState.guessing > 0) return;
String prefix = "<-" + StringHelper.repeat( '-', (--traceDepth * 2) ) + " ";
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.
* 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.
* 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.
*/
private SqlWriter writer = new DefaultWriter();
@ -77,10 +77,11 @@ public class SqlGenerator extends SqlGeneratorBase implements ErrorReporter {
// handle trace logging ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
private int traceDepth = 0;
private int traceDepth = 0;
@Override
public void traceIn(String ruleName, AST tree) {
if (!LOG.isTraceEnabled()) return;
if (inputState.guessing > 0) return;
String prefix = StringHelper.repeat( '-', (traceDepth++ * 2) ) + "-> ";
String traceText = ruleName + " (" + buildTraceNodeName(tree) + ")";
@ -95,6 +96,7 @@ public class SqlGenerator extends SqlGeneratorBase implements ErrorReporter {
@Override
public void traceOut(String ruleName, AST tree) {
if (!LOG.isTraceEnabled()) return;
if (inputState.guessing > 0) return;
String prefix = "<-" + StringHelper.repeat( '-', (--traceDepth * 2) ) + " ";
LOG.trace(prefix + ruleName);

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