diff options
author | Mike Krüger <mikkrg@microsoft.com> | 2018-02-26 12:06:29 +0300 |
---|---|---|
committer | Mike Krüger <mikkrg@microsoft.com> | 2018-02-26 12:06:29 +0300 |
commit | ab5298c774820cf6c8df2ba7f61c15ad4e76ea48 (patch) | |
tree | 99cdc1590b3b088755f8861986896159771bd771 /main/src/addins/MonoDevelop.DocFood | |
parent | af8ec9f97fd5c4c131e3d66a07c3fcd75f3ae76e (diff) |
[MonoDevelop.DocFood] Use StringBuilderCache.
Diffstat (limited to 'main/src/addins/MonoDevelop.DocFood')
-rw-r--r-- | main/src/addins/MonoDevelop.DocFood/MonoDevelop.DocFood/Commands.cs | 12 | ||||
-rw-r--r-- | main/src/addins/MonoDevelop.DocFood/MonoDevelop.DocFood/DocGenerator.cs | 12 |
2 files changed, 13 insertions, 11 deletions
diff --git a/main/src/addins/MonoDevelop.DocFood/MonoDevelop.DocFood/Commands.cs b/main/src/addins/MonoDevelop.DocFood/MonoDevelop.DocFood/Commands.cs index e83619fdf9..6d641dfacf 100644 --- a/main/src/addins/MonoDevelop.DocFood/MonoDevelop.DocFood/Commands.cs +++ b/main/src/addins/MonoDevelop.DocFood/MonoDevelop.DocFood/Commands.cs @@ -31,6 +31,7 @@ using System.Text; using Microsoft.CodeAnalysis; using System.Linq; using MonoDevelop.Ide.Editor; +using MonoDevelop.Core; namespace MonoDevelop.DocFood { @@ -130,7 +131,7 @@ namespace MonoDevelop.DocFood internal static string GenerateDocumentation (IReadonlyTextDocument data, ISymbol member, string indent, string prefix) { - StringBuilder result = new StringBuilder (); + StringBuilder result = StringBuilderCache.Allocate (); var generator = new DocGenerator (data); generator.GenerateDoc (member); @@ -168,7 +169,7 @@ namespace MonoDevelop.DocFood } bool inTag = false; int column = indent.Length + prefix.Length; - StringBuilder curWord = new StringBuilder (); + StringBuilder curWord = StringBuilderCache.Allocate (); foreach (char ch in section.Documentation) { if (ch == '<') inTag = true; @@ -213,14 +214,15 @@ namespace MonoDevelop.DocFood result.Append ("</"); result.Append (section.Name); result.Append (">"); + StringBuilderCache.ReturnAndFree (curWord); } result.AppendLine (); - return result.ToString (); + return StringBuilderCache.ReturnAndFree (result); } internal static string GenerateEmptyDocumentation (IReadonlyTextDocument data, ISymbol member, string indent) { - StringBuilder result = new StringBuilder (); + StringBuilder result = StringBuilderCache.Allocate (); DocGenerator generator = new DocGenerator (data); generator.GenerateDoc (member); @@ -266,7 +268,7 @@ namespace MonoDevelop.DocFood result.Append (">"); } result.AppendLine (); - return result.ToString (); + return StringBuilderCache.ReturnAndFree (result); } } diff --git a/main/src/addins/MonoDevelop.DocFood/MonoDevelop.DocFood/DocGenerator.cs b/main/src/addins/MonoDevelop.DocFood/MonoDevelop.DocFood/DocGenerator.cs index 77f36c6617..88d441805d 100644 --- a/main/src/addins/MonoDevelop.DocFood/MonoDevelop.DocFood/DocGenerator.cs +++ b/main/src/addins/MonoDevelop.DocFood/MonoDevelop.DocFood/DocGenerator.cs @@ -88,7 +88,7 @@ namespace MonoDevelop.DocFood { if (string.IsNullOrEmpty (xmlDoc)) return; - StringBuilder sb = new StringBuilder (); + StringBuilder sb = StringBuilderCache.Allocate (); sb.Append ("<root>"); bool wasWs = false; foreach (char ch in xmlDoc) { @@ -105,7 +105,7 @@ namespace MonoDevelop.DocFood } sb.Append ("</root>"); try { - using (var reader = XmlTextReader.Create (new System.IO.StringReader (sb.ToString ()))) { + using (var reader = XmlTextReader.Create (new System.IO.StringReader (StringBuilderCache.ReturnAndFree (sb)))) { while (reader.Read ()) { if (reader.NodeType != XmlNodeType.Element) continue; @@ -447,7 +447,7 @@ namespace MonoDevelop.DocFood var parameters = property != null? property.Parameters : method.Parameters; var parameterNames = new List<string> (from p in parameters select p.Name); tags ["ParameterSentence"] = string.Join (" ", parameterNames.ToArray ()); - StringBuilder paramList = new StringBuilder (); + StringBuilder paramList = StringBuilderCache.Allocate (); for (int i = 0; i < parameterNames.Count; i++) { if (i > 0) { if (i == parameterNames.Count - 1) { @@ -458,7 +458,7 @@ namespace MonoDevelop.DocFood } paramList.Append (parameterNames [i]); } - tags ["ParameterList"] = paramList.ToString (); + tags ["ParameterList"] = StringBuilderCache.ReturnAndFree (paramList); for (int i = 0; i < parameters.Length; i++) { tags ["Parameter" + i + ".Type"] = parameters [i].Type != null ? "<see cref=\"" + parameters [i].Type + "\"/>" : ""; tags ["Parameter" + i + ".Name"] = "<c>" + parameters [i].Name + "</c>"; @@ -940,7 +940,7 @@ namespace MonoDevelop.DocFood static string SeparateWords (string name) { - var result = new StringBuilder (); + var result = StringBuilderCache.Allocate (); bool wasUnderscore = false; for (int i = 0; i < name.Length; i++) { char ch = name [i]; @@ -975,7 +975,7 @@ namespace MonoDevelop.DocFood result.Append (char.ToLower (ch)); } - return result.ToString (); + return StringBuilderCache.ReturnAndFree (result); } static ImmutableArray<IParameterSymbol> GetParameters (ISymbol symbol) |