commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject svn commit: r564712 - /commons/proper/el/trunk/src/java/org/apache/commons/el/ExpressionEvaluatorImpl.java
Date Fri, 10 Aug 2007 18:31:18 GMT
Author: mbenson
Date: Fri Aug 10 11:31:17 2007
New Revision: 564712

URL: http://svn.apache.org/viewvc?view=rev&rev=564712
Log:
refactor parse

Modified:
    commons/proper/el/trunk/src/java/org/apache/commons/el/ExpressionEvaluatorImpl.java

Modified: commons/proper/el/trunk/src/java/org/apache/commons/el/ExpressionEvaluatorImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/el/trunk/src/java/org/apache/commons/el/ExpressionEvaluatorImpl.java?view=diff&rev=564712&r1=564711&r2=564712
==============================================================================
--- commons/proper/el/trunk/src/java/org/apache/commons/el/ExpressionEvaluatorImpl.java (original)
+++ commons/proper/el/trunk/src/java/org/apache/commons/el/ExpressionEvaluatorImpl.java Fri
Aug 10 11:31:17 2007
@@ -240,28 +240,29 @@
         }
 
         // See if it's in the cache
-        Object ret = mBypassCache ? null : sCachedExpressionStrings
-                .get(pExpressionString);
+        if (!mBypassCache
+                && sCachedExpressionStrings.containsKey(pExpressionString)) {
+            return sCachedExpressionStrings.get(pExpressionString);
+        }
 
-        if (ret == null) {
-            // Parse the expression
-            Reader r = new StringReader(pExpressionString);
-            ELParser parser = new ELParser(r);
-            try {
-                ret = parser.ExpressionString();
-                sCachedExpressionStrings.put(pExpressionString, ret);
-            } catch (ParseException exc) {
-                throw new ELException(formatParseException(pExpressionString,
-                        exc));
-            } catch (TokenMgrError exc) {
-                // Note - this should never be reached, since the parser is
-                // constructed to tokenize any input (illegal inputs get
-                // parsed to <BADLY_ESCAPED_STRING_LITERAL> or
-                // <ILLEGAL_CHARACTER>
-                throw new ELException(exc.getMessage());
+        // Parse the expression
+        Reader r = new StringReader(pExpressionString);
+        ELParser parser = new ELParser(r);
+        try {
+            Object result = parser.ExpressionString();
+            if (!mBypassCache) {
+                sCachedExpressionStrings.put(pExpressionString, result);
             }
+            return result;
+        } catch (ParseException exc) {
+            throw new ELException(formatParseException(pExpressionString, exc));
+        } catch (TokenMgrError exc) {
+            // Note - this should never be reached, since the parser is
+            // constructed to tokenize any input (illegal inputs get
+            // parsed to <BADLY_ESCAPED_STRING_LITERAL> or
+            // <ILLEGAL_CHARACTER>
+            throw new ELException(exc.getMessage());
         }
-        return ret;
     }
 
     // -------------------------------------



Mime
View raw message