cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From giac...@apache.org
Subject svn commit: r416676 - /cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/util/WildcardMatcherHelper.java
Date Fri, 23 Jun 2006 11:31:59 GMT
Author: giacomo
Date: Fri Jun 23 04:31:54 2006
New Revision: 416676

URL: http://svn.apache.org/viewvc?rev=416676&view=rev
Log:
equal code sequence optimization

Modified:
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/util/WildcardMatcherHelper.java

Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/util/WildcardMatcherHelper.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/util/WildcardMatcherHelper.java?rev=416676&r1=416675&r2=416676&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/util/WildcardMatcherHelper.java
(original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/util/WildcardMatcherHelper.java
Fri Jun 23 04:31:54 2006
@@ -216,18 +216,7 @@
                 // if we reached the end of the pattern just do a string compare with the
corresponding part from 
                 // the end of the string
                 if(ipat >= lpat) {
-                    // if the remaining length of the string isn't the same as that found
in the pattern 
-                    // we do not match
-                    final int l = lpat - sipat; // calculate length of comparison
-                    final int ostr = lstr - l; // calculate offset into string
-                    if(ostr >= 0 && strncmp(apat, sipat, astr, ostr, l)) {
-                        add(new String(astr, istr, ostr - istr));
-
-                        return true;
-                    }
-
-                    // otherwise we do not match
-                    return false;
+                    return checkEnds(sipat);
                 }
 
                 // Now we need to check whether the litteral substring of the pattern 
@@ -272,19 +261,10 @@
                     ipat++;
                 }
 
-                // if we reached the end of the pattern just do a String compare with the
corresponding part from 
+                // if we reached the end of the pattern just do a string compare with the
corresponding part from 
                 // the end of the string
                 if(ipat >= lpat) {
-                    final int l = ipat - sipat; // calculate length of comparison
-                    final int ostr = lstr - l; // calculate offset into string
-                    if(ostr >= 0 && strncmp(apat, sipat, astr, ostr, l)) {
-                        add(new String(astr, istr, ostr - istr));
-
-                        return true;
-                    }
-
-                    // otherwise we do not match
-                    return false;
+                    return checkEnds(sipat);
                 }
 
                 // Now we need to check whether the litteral substring of the pattern 
@@ -311,7 +291,7 @@
         /**
          * Scan a possible common suffix
          */
-        private void scanLiteralPrefix() {
+        private final void scanLiteralPrefix() {
             // scan a common literal suffix
             while(ipat < lpat &&
                   istr < lstr &&
@@ -334,7 +314,7 @@
          *
          * @return Whether the all the mentioned characters match each other
          */
-        private boolean strncmp(final char[] a1,
+        private final boolean strncmp(final char[] a1,
                                 final int o1,
                                 final char[] a2,
                                 final int o2,
@@ -347,6 +327,22 @@
             while(i < l && o1 + i < a1.length && o2 + i < a2.length
&& a1[o1 + i] == a2[o2 + i]) i++;
 
             return i == l;
+        }
+        
+        private final boolean checkEnds(final int sipat)
+        {
+            // if the remaining length of the string isn't the same as that found in the
pattern 
+            // we do not match
+            final int l = lpat - sipat; // calculate length of comparison
+            final int ostr = lstr - l; // calculate offset into string
+            if(ostr >= 0 && strncmp(apat, sipat, astr, ostr, l)) {
+                add(new String(astr, istr, ostr - istr));
+
+                return true;
+            }
+
+            // otherwise we do not match
+            return false;
         }
     }
 }



Mime
View raw message