[Mono-devel-list] Patch for System.Text.RegularExpressions

Paolo Molaro lupus at ximian.com
Fri Nov 21 10:34:44 EST 2003


On 11/19/03 Juraj Skripsky wrote:
> Attached is a patch for System.Text.RegularExpression.QuickSearch and a
> new test case (which goes into
> class/System/Test/System.Text.RegularExpressions).
> 
> This will also reduce memory consumption quite a bit when using regular
> expressions.
> 
> * quicksearch.cs: Use hashtable instead of array (which should have had
> size 0x10000 instead of 0x1000 in the first place) for shift table.

I posted a patch that addressed the same issue a while ago (included at
the end of the mail). It disables the boyer-moore algorithm completely,
because it really doesn't buy us anything. At the very least, it should
be used only when the search string is very large, but even in that case
we should do some measurements to see if it really is effective.
I saw miguel committed your patch, but the real fix is to not use the
QuickSearch class at all. That will fix both speed and memory
consumption issues. Care to remove the use of the class from
interpreter.cs and simply do a 'dumb' search as with the patch?

> * RegexTest.cs: New test case using a string containing a character >
> 0x1000.
> 
> Should I send future ChangeLog entries as diffs as well?

Yes, please also send ChangeLog entries.

Thanks.

lupus

-- 
-----------------------------------------------------------------
lupus at debian.org                                     debian/rules
lupus at ximian.com                             Monkeys do it better

Index: quicksearch.cs
===================================================================
RCS file: /cvs/public/mcs/class/System/System.Text.RegularExpressions/quicksearch.cs,v
retrieving revision 1.1
diff -u -p -r1.1 quicksearch.cs
--- quicksearch.cs	31 Jan 2002 08:00:16 -0000	1.1
+++ quicksearch.cs	7 Oct 2003 13:30:19 -0000
@@ -20,7 +20,7 @@ namespace System.Text.RegularExpressions
 			this.len = str.Length;
 			this.ignore = ignore;
 		
-			Setup ();
+			//Setup ();
 		}
 		
 		public string String {
@@ -38,7 +38,7 @@ namespace System.Text.RegularExpressions
 		public int Search (string text, int start, int end) {
 			if (end > text.Length - len)
 				end = text.Length - len;
-		
+	
 			int ptr = start;
 			if (!ignore) {
 				while (ptr <= end) {
@@ -49,7 +49,7 @@ namespace System.Text.RegularExpressions
 					}
 
 					if (ptr < end)
-						ptr += shift[text[ptr + len]];
+						ptr++;
 					else
 						break;
 				}
@@ -66,7 +66,7 @@ namespace System.Text.RegularExpressions
 					}
 
 					if (ptr < end)
-						ptr += shift[text[ptr + len]];
+						ptr++;
 					else
 						break;
 				}



More information about the Mono-devel-list mailing list