[jboss-jira] [JBoss JIRA] (DROOLS-592) Condition Evaluator should instantiate argument only once.

david hendi (JIRA) issues at jboss.org
Wed Sep 3 21:46:02 EDT 2014


david hendi created DROOLS-592:
----------------------------------

             Summary: Condition Evaluator should instantiate argument only once.
                 Key: DROOLS-592
                 URL: https://issues.jboss.org/browse/DROOLS-592
             Project: Drools
          Issue Type: Feature Request
      Security Level: Public (Everyone can see)
    Affects Versions: 6.2.0.Beta1
            Reporter: david hendi
            Assignee: Mark Proctor
            Priority: Optional


the argument(s) used within the evaluate method of a Conditional Evaluator should instantiate argument only once in order to reduce object creation and GC. 

current generated class:
public class ConditionEvaluatorfff283c427e34a39877bce16cac05521
  implements ConditionEvaluator
{
  private static final String EXPRESSION = "!( ids contains 614201302l )";
  private final Declaration[] declarations;
  
  public ConditionEvaluatorfff283c427e34a39877bce16cac05521(Declaration[] paramArrayOfDeclaration)
  {
    this.declarations = paramArrayOfDeclaration;
  }
  
  public boolean evaluate(InternalFactHandle paramInternalFactHandle, InternalWorkingMemory paramInternalWorkingMemory, LeftTuple paramLeftTuple)
  {
    Collection localCollection = ((Context)paramInternalFactHandle.getObject()).getIds();
    Long localLong = new Long("614201302");
    return !(localLong == null ? false : localCollection == null ? false : EvaluatorHelper.contains(localCollection, localLong));
  }
}


proposed class:
public class ConditionEvaluatorfff283c427e34a39877bce16cac05521
  implements ConditionEvaluator
{
  private static final String EXPRESSION = "!( ids contains 614201302l )";
  private static Long localLong = new Long("614201302");
  private final Declaration[] declarations;
  
  public ConditionEvaluatorfff283c427e34a39877bce16cac05521(Declaration[] paramArrayOfDeclaration)
  {
    this.declarations = paramArrayOfDeclaration;
  }
  
  public boolean evaluate(InternalFactHandle paramInternalFactHandle, InternalWorkingMemory paramInternalWorkingMemory, LeftTuple paramLeftTuple)
  {
    Collection localCollection = ((Context)paramInternalFactHandle.getObject()).getIds();
    
    return !(localLong == null ? false : localCollection == null ? false : EvaluatorHelper.contains(localCollection, localLong));
  }
}




--
This message was sent by Atlassian JIRA
(v6.3.1#6329)


More information about the jboss-jira mailing list