Skip to content
This repository has been archived by the owner on Sep 4, 2024. It is now read-only.

Commit

Permalink
[Misc] Remove some extra string allocations.
Browse files Browse the repository at this point in the history
  • Loading branch information
Therzok committed Jul 12, 2016
1 parent 4247708 commit cd46027
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Mono.Addins.Gui/Mono.Addins.Gui/AddinTreeWidget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ string EscapeWithFilterMarker (string txt)
int i = txt.IndexOf (filter, StringComparison.CurrentCultureIgnoreCase);
while (i != -1) {
sb.Append (GLib.Markup.EscapeText (txt.Substring (last, i - last)));
sb.Append ("<span color='blue'>").Append (txt.Substring (i, filter.Length)).Append ("</span>");
sb.Append ("<span color='blue'>").Append (txt, i, filter.Length).Append ("</span>");
last = i + filter.Length;
i = txt.IndexOf (filter, last, StringComparison.CurrentCultureIgnoreCase);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ void WriteLog (string text)
pi = i + 1;
i = text.IndexOf ('\n', pi);
}
logBuffer.Append (text.Substring (pi));
logBuffer.Append (text, pi, text.Length - pi);
}

public TextWriter Log {
Expand Down
4 changes: 2 additions & 2 deletions Mono.Addins.Setup/Mono.Addins.Setup/PcFileCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ string Evaluate (string value)
StringBuilder sb = new StringBuilder ();
int last = 0;
while (i != -1 && i < value.Length) {
sb.Append (value.Substring (last, i - last));
sb.Append (value, last, i - last);
if (i == 0 || value [i - 1] != '$') {
// Evaluate if var is not escaped
i += 2;
Expand All @@ -572,7 +572,7 @@ string Evaluate (string value)
if (i < value.Length - 1)
i = value.IndexOf ("${", i);
}
sb.Append (value.Substring (last, value.Length - last));
sb.Append (value, last, value.Length - last);
return sb.ToString ();
}
}
Expand Down
2 changes: 1 addition & 1 deletion Mono.Addins.Setup/Mono.Addins.Setup/TextFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public void Append (string text)
}

if (n != sn)
currentWord.Append (text.Substring (sn, n - sn));
currentWord.Append (text, sn, n - sn);
if (foundSpace) {
AppendCurrentWord (text[n]);
n++;
Expand Down
3 changes: 2 additions & 1 deletion Mono.Addins/Mono.Addins.Description/AddinDescription.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1009,7 +1009,8 @@ internal string ParseString (string input)
if (i == -1)
return input;

StringBuilder result = new StringBuilder (input.Substring (0, i), input.Length);
StringBuilder result = new StringBuilder (input.Length);
result.Append (input, 0, i);

while (i < input.Length) {
if (input [i] == '$') {
Expand Down

0 comments on commit cd46027

Please sign in to comment.