本文整理汇总了C#中System.Text.StringBuilder.EnsureCapacity方法的典型用法代码示例。如果您正苦于以下问题:C# System.Text.StringBuilder.EnsureCapacity方法的具体用法?C# System.Text.StringBuilder.EnsureCapacity怎么用?C# System.Text.StringBuilder.EnsureCapacity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Text.StringBuilder
的用法示例。
在下文中一共展示了System.Text.StringBuilder.EnsureCapacity方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Index
//-------------------------------------------------------------------
public void Index(MemManager.Log.Log lg)
{
System.Collections.Hashtable cache = new System.Collections.Hashtable(4096);
int processed = 0;
System.Text.StringBuilder addresses = new System.Text.StringBuilder();
addresses.EnsureCapacity(32768);
// Work out all unique addresses
for (int i = 0; i < lg.Count; i++)
{
int index = lg[i].stackTraceString;
if (index <= processed)
continue;
processed = index;
string callstack = lg.GetString(index);
string[] addrarray = callstack.Split(' ');
foreach (string s in addrarray)
{
if (!cache.ContainsKey(s))
{
cache[s] = s;
addresses.Append(s);
addresses.Append(' ');
// Fix issue with nasty command line length issue on win32.
if (addresses.Length >= 32000)
{
Index(addresses.ToString());
// Wipe addresses
addresses = new System.Text.StringBuilder();
addresses.EnsureCapacity(32768);
}
}
}
}
// Index unique addresses
if (addresses.Length > 0)
Index(addresses.ToString());
}
示例2: joinPath
internal static string joinPath(Interp interp, TclObject[] argv, int startIndex, int endIndex)
{
System.Text.StringBuilder result = new System.Text.StringBuilder(10);
switch (JACL.PLATFORM)
{
case JACL.PLATFORM_WINDOWS:
for (int i = startIndex; i < endIndex; i++)
{
string p = argv[i].ToString().Replace('\\', '/');
int pIndex = 0;
int pLastIndex = p.Length - 1;
if (p.Length == 0)
{
continue;
}
System.Text.StringBuilder absBuf = new System.Text.StringBuilder(0);
pIndex = getWinAbsPath(p, absBuf);
if (pIndex > 0)
{
// If the path is absolute or volume relative (except those
// beginning with '~'), reset the result buffer to the absolute
// substring.
result = absBuf;
}
else if (p[0] == '~')
{
// If the path begins with '~', reset the result buffer to "".
result.Length = 0;
}
else
{
// This is a relative path. Remove the ./ from tilde prefixed
// elements unless it is the first component.
if ((result.Length != 0) && (String.Compare(p, pIndex, "./~", 0, 3) == 0))
{
pIndex = 2;
}
// Check to see if we need to append a separator before adding
// this relative component.
if (result.Length != 0)
{
char c = result[result.Length - 1];
if ((c != '/') && (c != ':'))
{
result.EnsureCapacity(result.Length + 1);
result.Append('/');
}
}
}
// Append the element.
appendComponent(p, pIndex, pLastIndex, result);
pIndex = p.Length;
}
return result.ToString();
case JACL.PLATFORM_MAC:
bool needsSep = true;
for (int i = startIndex; i < endIndex; i++)
{
TclObject[] splitArrayObj = TclList.getElements(interp, splitPath(interp, argv[i].ToString()));
if (splitArrayObj.Length == 0)
{
continue;
}
// If 1st path element is absolute, reset the result to "" and
// append the 1st path element to it.
int start = 0;
string p = splitArrayObj[0].ToString();
if ((p[0] != ':') && (p.IndexOf((System.Char) ':') != - 1))
{
result.Length = 0;
result.Append(p);
start++;
needsSep = false;
}
// Now append the rest of the path elements, skipping
//.........这里部分代码省略.........