Skip to content

Commit

Permalink
2004-11-08 Ben Maurer <bmaurer@ximian.com>
Browse files Browse the repository at this point in the history
	* replace.cs, parser.cs: Use stringbuilder for allocation sanity.

svn path=/trunk/mcs/; revision=35869
  • Loading branch information
Ben Maurer committed Nov 9, 2004
1 parent 17a1919 commit e2a91c4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
4 changes: 4 additions & 0 deletions mcs/class/System/System.Text.RegularExpressions/ChangeLog
@@ -1,3 +1,7 @@
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>

* regex.cs: Fixed a bug introduced with the last patch which
Expand Down
6 changes: 3 additions & 3 deletions mcs/class/System/System.Text.RegularExpressions/parser.cs
Expand Up @@ -1048,7 +1048,7 @@ class Parser {
this.pattern = pattern;
this.ptr = 0;

string result = "";
StringBuilder result = new StringBuilder (pattern.Length);
while (ptr < pattern.Length) {
int c = pattern[ptr ++];
if (c == '\\') {
Expand All @@ -1060,10 +1060,10 @@ class Parser {
c = '\b';
}
}
result += (char)c;
result.Append (c);
}

return result;
return result.ToString ();
}

private void ResolveReferences () {
Expand Down
10 changes: 5 additions & 5 deletions mcs/class/System/System.Text.RegularExpressions/replace.cs
Expand Up @@ -59,7 +59,7 @@ class ReplacementEvaluator {

private void Compile (string replacement) {
replacement = Parser.Unescape (replacement);
string literal = "";
StringBuilder literal = new StringBuilder ();

int ptr = 0;
char c;
Expand All @@ -75,18 +75,18 @@ class ReplacementEvaluator {
}

if (term != null) {
term.Literal = literal;
term.Literal = literal.ToString ();
terms.Add (term);

term = null;
literal = "";
literal.Length = 0;
}
else
literal += c;
literal.Append (c);
}

if (term == null && literal.Length > 0) {
terms.Add (new Term (literal));
terms.Add (new Term (literal.ToString ()));
}
}

Expand Down

0 comments on commit e2a91c4

Please sign in to comment.