StringBuilder -- 字符串处理对象
(创建时间:2010年11月08日 19:18:00)
Jangogo : 

用VB处理字符串的拼接和删除部分内容等字符串操作非常缓慢。

这个对象专门用于解决字符串处理慢的问题。

' ======================================================================================
' Name:     vbAccelerator cStringBuilder
' Author:   Steve McMahon (steve@vbaccelerator.com)
' Date:     1 January 2002
'
' Copyright ?2002 Steve McMahon for vbAccelerator
' --------------------------------------------------------------------------------------
' Visit vbAccelerator - advanced free source code for VB programmers
' http://vbaccelerator.com
' --------------------------------------------------------------------------------------
'
' VB can be slow to append strings together because of the continual
' reallocation of string size.  This class pre-allocates a string in
' blocks and hence removes the performance restriction.
'
' Quicker insert and remove is also possible since string space does
' not have to be reallocated.
'
' Example:
' Adding "http://vbaccelerator.com/" 10,000 times to a string:
' Standard VB:   34s
' This Class:    0.35s
'
' ======================================================================================

StringBuilder用于快速处理大量的字符串的拼接,在以下语言中StringBuilder 比起直接的 += 的方式字符串拼接速度有10倍以上的提高:

VB6  /  VBScript  / 4Fang SC  /  .Net 系列

但是在IE8以上的浏览器内置Javascript 环境中,任何一种StringBuilder都没有 字符串的  加法来得快,所以我们不建议在IE8以上的 js 里面使用StringBuilder

文档中心