Bumping the chunk size in Dragokas' code certainly improves performance at the expense of memory of course. It's usually slightly faster than RC5 in this case.
I didn't try ConcatCollection because I don't see where that code is??
I've just tried using an array of Strings with Join$ for the Value and it is giving me the best performance now (CStringBuilderJ):
Some timings:Code:Option Explicit Public Enum e_AppendModifier [_appendmod_Ignore] = -1 ' Internal use appendmod_None appendmod_CrLf ' Append CRLF after primary append operation appendmod_Lf ' Append LF after primary append operation End Enum Private Const mc_BufferSize As Long = 128 Private ma_Strings() As String Private m_NextIndex As Long Private m_UndoBump As Long Private m_Undoable As Boolean Public Property Get Value() As String If UBound(ma_Strings) <> m_NextIndex - 1 Then ReDim Preserve ma_Strings(m_NextIndex - 1) End If Value = Join$(ma_Strings, "") End Property Public Sub Undo() Dim ii As Long If Not m_Undoable Then Err.Raise 5, , "Undo buffer is exhausted." If m_NextIndex = 0 Then Err.Raise 5, , "Nothing to undo." m_Undoable = False For ii = 0 To m_UndoBump m_NextIndex = m_NextIndex - 1 ma_Strings(m_NextIndex) = "" Next ii End Sub Public Sub Append(ByVal p_String As String, Optional ByVal p_Modifier As e_AppendModifier) Dim l_ReRun As Boolean m_Undoable = True Do If m_NextIndex = 0 Then ReDim ma_Strings(mc_BufferSize - 1) Else If m_NextIndex > UBound(ma_Strings) Then ReDim Preserve ma_Strings(UBound(ma_Strings) + mc_BufferSize - 1) End If End If ma_Strings(m_NextIndex) = p_String m_NextIndex = m_NextIndex + 1 If p_Modifier > appendmod_None Then m_UndoBump = 1 l_ReRun = True Select Case p_Modifier Case appendmod_CrLf p_Modifier = [_appendmod_Ignore] p_String = vbCrLf Case appendmod_Lf p_Modifier = [_appendmod_Ignore] p_String = vbLf End Select Else l_ReRun = False If p_Modifier = appendmod_None Then m_UndoBump = 0 End If End If Loop While l_ReRun End Sub
Dragokas (large buffer): 711.53ms
RC5: 880.38ms
jpbro: 589.47ms




Reply With Quote
