* replace.cs, parser.cs: Use stringbuilder for allocation sanity.
svn path=/trunk/mcs/; revision=35869
+2004-11-08 Ben Maurer <bmaurer@ximian.com>
+
+ * replace.cs, parser.cs: Use stringbuilder for allocation sanity.
+
2004-10-21 Joerg Rosenkranz <joergr@voelcker.com>\r
\r
* regex.cs: Fixed a bug introduced with the last patch which\r
this.pattern = pattern;
this.ptr = 0;
- string result = "";
+ StringBuilder result = new StringBuilder (pattern.Length);
while (ptr < pattern.Length) {
int c = pattern[ptr ++];
if (c == '\\') {
c = '\b';
}
}
- result += (char)c;
+ result.Append (c);
}
- return result;
+ return result.ToString ();
}
private void ResolveReferences () {
\r
private void Compile (string replacement) {\r
replacement = Parser.Unescape (replacement);\r
- string literal = "";\r
+ StringBuilder literal = new StringBuilder ();\r
\r
int ptr = 0;\r
char c;\r
}\r
\r
if (term != null) {\r
- term.Literal = literal;\r
+ term.Literal = literal.ToString ();\r
terms.Add (term);\r
\r
term = null;\r
- literal = "";\r
+ literal.Length = 0;\r
}\r
else\r
- literal += c;\r
+ literal.Append (c);\r
}\r
\r
if (term == null && literal.Length > 0) {\r
- terms.Add (new Term (literal));\r
+ terms.Add (new Term (literal.ToString ()));\r
}\r
}\r
\r