Jump to content

JREvaluator - Performance concerns


Recommended Posts

By: Paul Smith - tallpsmith_au

JREvaluator - Performance concerns

2006-03-05 17:03

The following code in JREvaluator appears to be a big problem in some of the profiling we've done (JREvaluator.java):

 

public Object evaluate(JRExpression expression) throws JRExpressionEvalException

{

Object value = null;

 

try

{

value = evaluate(expression.getId());

}

catch (NullPointerException e)

{

}

catch (OutOfMemoryError e)

{

throw e;

}

catch (Throwable e)

{

throw new JRExpressionEvalException(expression, e);

}

 

return value;

}

 

 

Rather than catch a NullPointerException, could a simple:

 

if(expression==null){ return null;}

 

be inserted instead? The cost of creating an exception will add up in a large report, and this will short-circuit it.

 

This change would need to be made in a number of other places in the same file that do something similar.

 

regards,

 

Paul Smith

 

 

By: Lucian Chirita - lucianc

RE: JREvaluator - Performance concerns

2006-03-06 01:02

You are right, a null test *should* be performed on the expression and this case should not throw an exception which is immediately caught.

 

However, the NPE catch is still required so that expressions like ..$V{var}.intValue().. evaluate to null when the value of "var" is null.

 

I will commit the changes to CVS.

 

Thank you,

Lucian

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...