当前位置: 首页>>代码示例>>C#>>正文


C# System.Text.StringBuilder.EnsureCapacity方法代码示例

本文整理汇总了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());
        }
开发者ID:arjangcore,项目名称:MemoryCompare,代码行数:44,代码来源:CallStackLookup.cs

示例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
//.........这里部分代码省略.........
开发者ID:Belxjander,项目名称:Asuna,代码行数:101,代码来源:FileUtil.cs


注:本文中的System.Text.StringBuilder.EnsureCapacity方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。