You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by te...@apache.org on 2006/06/22 21:49:27 UTC

svn commit: r416455 - in /incubator/harmony/enhanced/classlib/trunk/modules/regex/src/main/java/java/util/regex: BehindFSet.java PositiveLookBehind.java

Author: tellison
Date: Thu Jun 22 12:49:26 2006
New Revision: 416455

URL: http://svn.apache.org/viewvc?rev=416455&view=rev
Log:
Apply patch HARMONY-580 ([classlib][regex][perf] Lookaround matching is slow)

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/regex/src/main/java/java/util/regex/BehindFSet.java
    incubator/harmony/enhanced/classlib/trunk/modules/regex/src/main/java/java/util/regex/PositiveLookBehind.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/regex/src/main/java/java/util/regex/BehindFSet.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/regex/src/main/java/java/util/regex/BehindFSet.java?rev=416455&r1=416454&r2=416455&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/regex/src/main/java/java/util/regex/BehindFSet.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/regex/src/main/java/java/util/regex/BehindFSet.java Thu Jun 22 12:49:26 2006
@@ -39,11 +39,10 @@
 
         int gr = getGroupIndex();
         int rightBound = matchResult.getConsumed(gr);
-        matchResult.setConsumed(gr, -1);
         return (rightBound == stringIndex) ? stringIndex : -1;
     }
 
     protected String getName() {
         return "BehindFSet";
     }
-}
\ No newline at end of file
+}

Modified: incubator/harmony/enhanced/classlib/trunk/modules/regex/src/main/java/java/util/regex/PositiveLookBehind.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/regex/src/main/java/java/util/regex/PositiveLookBehind.java?rev=416455&r1=416454&r2=416455&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/regex/src/main/java/java/util/regex/PositiveLookBehind.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/regex/src/main/java/java/util/regex/PositiveLookBehind.java Thu Jun 22 12:49:26 2006
@@ -41,20 +41,23 @@
             MatchResultImpl matchResult) {
 
         int size = children.size();
-        int shift;
-
-        // fSet will take this index to check if we at the right bound
-        // and return true if the current index equal to this one
-        matchResult.setConsumed(groupIndex, stringIndex);
-
-        for (int i = 0; i < size; i++) {
-            AbstractSet e = (AbstractSet) children.get(i);
-            // find limits could be calculated though e.getCharCount()
-            // fSet will return true only if string index at fSet equal
-            // to stringIndex
-            shift = e.findBack(0, stringIndex, testString, matchResult);
-            if (shift >= 0) {
-                return next.matches(stringIndex, testString, matchResult);
+        int leftBound = matchResult.hasTransparentBounds()?
+                0 : matchResult.getLeftBound();
+        
+        int shift = next.matches(stringIndex, testString, matchResult);
+        if (shift >= 0) {
+            //fSet will take this index to check if we at the right bound
+            // and return true if the current index equal to this one
+            matchResult.setConsumed(groupIndex, stringIndex);
+            for (int i = 0; i < size; i++) {
+                AbstractSet e = (AbstractSet) children.get(i);
+                // find limits could be calculated though e.getCharCount()
+                // fSet will return true only if string index at fSet equal
+                // to stringIndex
+                if (e.findBack(leftBound, stringIndex, testString, matchResult) >=0) {
+                    matchResult.setConsumed(groupIndex, -1);
+                    return shift;
+                }    
             }
         }