incubator-imperius-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Xiping Wang <xip...@us.ibm.com>
Subject Re: svn commit: r779776 - in /incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl: LogicalAnd.java LogicalOr.java
Date Fri, 29 May 2009 13:11:23 GMT

David,

I am not sure what the difference is between your changes and the original
code. I thought you wanted to optimize the code by simplifying evaluation
process as I described below. Am I missing something?

//for LogicalAnd
boolean left = ((Boolean) _lhsExp.evaluate()).booleanValue();
if (!left) return Boolean(false) //no further evaluation


//for LogicalOr
boolean left = ((Boolean) _lhsExp.evaluate()).booleanValue();
if (left) return Boolean(true) //no further evaluation

In addition, the left hand side or the right hand side can be a constant
expression, so a constant expression can always be eliminated when a
logical expression is created.

Xiping




                                                                           
             dawood@apache.org                                             
                                                                           
             05/28/2009 05:18                                           To 
             PM                        imperius-commits@incubator.apache.o 
                                       rg                                  
                                                                        cc 
             Please respond to                                             
             imperius-dev@incu                                     Subject 
             bator.apache.org          svn commit: r779776 -               
                                       in /incubator/imperius/trunk/imperi 
                                       us-splcore/src/main/java/org/apache 
                                       /imperius/spl/parser/expressions/im 
                                       pl: LogicalAnd.java LogicalOr.java  
                                                                           
                                                                           
                                                                           
                                                                           
                                                                           
                                                                           




Author: dawood
Date: Thu May 28 21:18:43 2009
New Revision: 779776

URL: http://svn.apache.org/viewvc?rev=779776&view=rev
Log:
implement short-circuited evaluation.

Modified:

incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/LogicalAnd.java


incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/LogicalOr.java


Modified:
incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/LogicalAnd.java

URL:
http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/LogicalAnd.java?rev=779776&r1=779775&r2=779776&view=diff

==============================================================================

---
incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/LogicalAnd.java
 (original)
+++
incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/LogicalAnd.java
 Thu May 28 21:18:43 2009
@@ -76,7 +76,7 @@
         try
         {
             boolean left = ((Boolean) _lhsExp.evaluate()).booleanValue();
-            boolean right = ((Boolean) _rhsExp.evaluate()).booleanValue();
+            boolean right = left && ((Boolean) _rhsExp.evaluate
()).booleanValue();

             logger.exiting(sourceClass,Thread.currentThread().getName()+"
"+ "evaluate");


Modified:
incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/LogicalOr.java

URL:
http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/LogicalOr.java?rev=779776&r1=779775&r2=779776&view=diff

==============================================================================

---
incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/LogicalOr.java
 (original)
+++
incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/expressions/impl/LogicalOr.java
 Thu May 28 21:18:43 2009
@@ -79,7 +79,7 @@
         {
            //System.out.println("Logical OR::LHS type: RHS type ::"+
lhsExp.getType() + ":" + rhsExp.getType());
             boolean left = ((Boolean) _lhsExp.evaluate()).booleanValue();
-            boolean right = ((Boolean) _rhsExp.evaluate()).booleanValue();
+            boolean right = left || ((Boolean) _rhsExp.evaluate
()).booleanValue();
            //System.out.println("Logical OR::after Evaluation LHS:
RHS ::"+ left + ":" + right);
             logger.exiting(sourceClass,Thread.currentThread().getName()+"
"+ "evaluate");




Mime
  • Unnamed multipart/related (inline, None, 0 bytes)
View raw message