소스 검색

2002-08-28 Juli Mallett <[email protected]>

	* arch.cs, compiler.cs: Give the interpreter machine a property
	for the retrieval of the group count.

	* regex.cs: Use the new GroupCount property of the factory to
	initialise the current group count, and restructure code to compile
	the pattern only the first time it is needed (essentially backing
	out the previous revision of regex.cs, to use the new code.)

svn path=/trunk/mcs/; revision=7132
Juli Mallett 23 년 전
부모
커밋
e4cff48d9a

+ 10 - 0
mcs/class/System/System.Text.RegularExpressions/ChangeLog

@@ -1,3 +1,13 @@
+2002-08-28  Juli Mallett  <[email protected]>
+
+	* arch.cs, compiler.cs: Give the interpreter machine a property
+	for the retrieval of the group count.
+
+	* regex.cs: Use the new GroupCount property of the factory to
+	initialise the current group count, and restructure code to compile
+	the pattern only the first time it is needed (essentially backing
+	out the previous revision of regex.cs, to use the new code.)
+
 2002-08-14  Cesar Octavio Lopez Nataren <[email protected]>
 
 	* regex.cs: Added the ctr for ISerializable implementation and

+ 1 - 0
mcs/class/System/System.Text.RegularExpressions/arch.cs

@@ -81,6 +81,7 @@ namespace System.Text.RegularExpressions {
 
 	interface IMachineFactory {
 		IMachine NewInstance ();
+		int GroupCount { get; }
 	}
 
 	// Anchor SKIP OFFSET

+ 4 - 0
mcs/class/System/System.Text.RegularExpressions/compiler.cs

@@ -66,6 +66,10 @@ namespace System.Text.RegularExpressions {
 			return new Interpreter (pattern);
 		}
 
+		public int GroupCount {
+			get { return pattern[0]; }
+		}
+
 		private ushort[] pattern;
 	}
 

+ 8 - 6
mcs/class/System/System.Text.RegularExpressions/regex.cs

@@ -146,14 +146,14 @@ namespace System.Text.RegularExpressions {
 		
 			this.factory = cache.Lookup (pattern, options);
 
-			// parse and install group mapping
+			if (this.factory == null) {
+				// parse and install group mapping
 
-			Parser psr = new Parser ();
-			RegularExpression re = psr.ParseRegularExpression (pattern, options);
-			this.group_count = re.GroupCount;
-			this.mapping = psr.GetMapping ();
+				Parser psr = new Parser ();
+				RegularExpression re = psr.ParseRegularExpression (pattern, options);
+				this.group_count = re.GroupCount;
+				this.mapping = psr.GetMapping ();
 
-			if (this.factory == null) {
 				// compile
 				
 				ICompiler cmp;
@@ -169,6 +169,8 @@ namespace System.Text.RegularExpressions {
 
 				this.factory = cmp.GetMachineFactory ();
 				cache.Add (pattern, options, this.factory);
+			} else {
+				this.group_count = this.factory.GroupCount;
 			}
 		}