ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gscok...@apache.org
Subject svn commit: r683564 - in /ant/ivy/core/trunk: CHANGES.txt src/java/org/apache/ivy/core/module/id/ModuleRules.java
Date Thu, 07 Aug 2008 09:24:56 GMT
Author: gscokart
Date: Thu Aug  7 02:24:54 2008
New Revision: 683564

URL: http://svn.apache.org/viewvc?rev=683564&view=rev
Log:
Improve performance (IVY-872)

Modified:
    ant/ivy/core/trunk/CHANGES.txt
    ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ModuleRules.java

Modified: ant/ivy/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/CHANGES.txt?rev=683564&r1=683563&r2=683564&view=diff
==============================================================================
--- ant/ivy/core/trunk/CHANGES.txt (original)
+++ ant/ivy/core/trunk/CHANGES.txt Thu Aug  7 02:24:54 2008
@@ -102,6 +102,7 @@
 - IMPROVEMENT: Smarter determination if an expression is exact or not for RegexpPatternMatcher
and GlobPatternMatcher
 - IMPROVEMENT: Check branch consistency during resolve (IVY-858)
 - IMPROVEMENT: Give the possibility to not compute ivy.deps.changed (IVY-876)
+- IMPROVEMENT: Improve performance (IVY-872)
 
 - FIX: Incorrect parsing artifactPattern attribute in a sftp resolver (IVY-661) (thanks to
Alexey Kiselev)
 - FIX: Maven2 "ejb" packaging is not supported (IVY-873)

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ModuleRules.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ModuleRules.java?rev=683564&r1=683563&r2=683564&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ModuleRules.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ModuleRules.java Thu Aug  7
02:24:54 2008
@@ -23,6 +23,7 @@
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Map.Entry;
 
 import org.apache.ivy.plugins.matcher.MapMatcher;
 import org.apache.ivy.util.Checks;
@@ -102,7 +103,7 @@
      * @return an array of rule objects matching the given {@link ModuleId}.
      */
     public Object[] getRules(ModuleId mid) {
-        return getRules(new ModuleRevisionId(mid, "", ""), NoFilter.INSTANCE);
+        return getRules(mid.getAttributes(), NoFilter.INSTANCE);
     }
 
     /**
@@ -138,7 +139,7 @@
      */
     public Object getRule(ModuleId mid, Filter filter) {
         Checks.checkNotNull(mid, "mid");
-        return getRule(new ModuleRevisionId(mid, "", ""), filter);
+        return getRule(mid.getAttributes(), filter);
     }
     
     /**
@@ -159,12 +160,17 @@
      */
     public Object getRule(ModuleRevisionId mrid, Filter filter) {
         Checks.checkNotNull(mrid, "mrid");
-        Checks.checkNotNull(filter, "filter");
-        
-        for (Iterator iter = rules.keySet().iterator(); iter.hasNext();) {
-            MapMatcher midm = (MapMatcher) iter.next();
-            if (midm.matches(mrid.getAttributes())) {
-                Object rule = rules.get(midm);
+        Checks.checkNotNull(filter, "filter");        
+        Map moduleAttributes = mrid.getAttributes();       
+        return getRule(moduleAttributes, filter);
+    }
+
+    private Object getRule(Map moduleAttributes, Filter filter) {
+        for (Iterator iter = rules.entrySet().iterator(); iter.hasNext();) {
+            Map.Entry ruleEntry = (Entry) iter.next();
+            MapMatcher midm = (MapMatcher) ruleEntry.getKey();            
+            if (midm.matches(moduleAttributes)) {
+                Object rule = ruleEntry.getValue();
                 if (filter.accept(rule)) {
                     return rule;
                 }
@@ -173,6 +179,9 @@
         return null;
     }
 
+    
+    
+    
     /**
      * Returns the rules object matching the given {@link ModuleRevisionId} and accepted
by the
      * given {@link Filter}, or an empty array if no rule applies.
@@ -188,13 +197,19 @@
      */
     public Object[] getRules(ModuleRevisionId mrid, Filter filter) {
         Checks.checkNotNull(mrid, "mrid");
-        Checks.checkNotNull(filter, "filter");
-        
+        Checks.checkNotNull(filter, "filter");      
+        Map moduleAttributes = mrid.getAttributes();
+        return getRules(moduleAttributes, filter);
+    }
+
+    
+    private Object[] getRules(Map moduleAttributes, Filter filter) {
         List matchingRules = new ArrayList();
-        for (Iterator iter = rules.keySet().iterator(); iter.hasNext();) {
-            MapMatcher midm = (MapMatcher) iter.next();
-            if (midm.matches(mrid.getAttributes())) {
-                Object rule = rules.get(midm);
+        for (Iterator iter = rules.entrySet().iterator(); iter.hasNext();) {
+            Map.Entry ruleEntry = (Entry) iter.next();
+            MapMatcher midm = (MapMatcher) ruleEntry.getKey();            
+            if (midm.matches(moduleAttributes)) {
+                Object rule = ruleEntry.getValue();
                 if (filter.accept(rule)) {
                     matchingRules.add(rule);
                 }



Mime
View raw message