cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mgen...@apache.org
Subject svn commit: r695931 - /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/Expression.java
Date Tue, 16 Sep 2008 15:02:24 GMT
Author: mgentry
Date: Tue Sep 16 08:02:23 2008
New Revision: 695931

URL: http://svn.apache.org/viewvc?rev=695931&view=rev
Log:
Reverted changes.  Expression is mutable and can be manipulated after being cached.

Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/Expression.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/Expression.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/Expression.java?rev=695931&r1=695930&r2=695931&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/Expression.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/exp/Expression.java
Tue Sep 16 08:02:23 2008
@@ -26,7 +26,6 @@
 import java.io.StringWriter;
 import java.util.Collection;
 import java.util.Collections;
-import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
@@ -120,36 +119,21 @@
 
     protected int type;
 
-    private static Map<String, Expression> expressionCache =
-        Collections.synchronizedMap(new HashMap<String, Expression>(32));
-
     /**
      * Parses string, converting it to Expression. If string does not represent a
      * semantically correct expression, an ExpressionException is thrown.
      * 
      * @since 1.1
      */
+    // TODO: cache expression strings, since this operation is pretty slow
     public static Expression fromString(String expressionString) {
         if (expressionString == null) {
             throw new NullPointerException("Null expression string.");
         }
 
-        // Retrieve, if possible, the expression from the cache.
-        Expression expression = expressionCache.get(expressionString);
-
-        // If the expression was cached, return it immediately without parsing.
-        if (expression != null)
-            return expression;
-
-        // Couldn't find expression, parse, cache, and return it.
+        Reader reader = new StringReader(expressionString);
         try {
-            Reader reader = new StringReader(expressionString);
-
-            expression = new ExpressionParser(reader).expression();
-
-            expressionCache.put(expressionString, expression);
-
-            return expression;
+            return new ExpressionParser(reader).expression();
         }
         catch (ParseException ex) {
             throw new ExpressionException(ex.getMessage(), ex);



Mime
View raw message