Search Tools Links Login

CStrCat v. 1.1


Faster version of StrCat posted by someone else. About 2x faster. About 6x faster than '& (ampersand)' operator for many concatenations.

Original Author: Neil McGuigan

Inputs

Does not need length property as it will increase the array size by 10% if it maxes out.
.add strPart

Assumptions

dim sc
set sc=new CStrCat
for i=0 to 10000
sc.add "whatever"
next
response.write sc.value

Returns

.value ~ whole string

API Declarations

Copyright (c) 2001, Neil McGuigan. All rights reserved. This software is licensed.

Code

<%
Class CStrCat //v1.1
Private i,sa()
Public Property Get Value
redim preserve sa(i)
Value=Join(sa,"")
End Property
Private Sub Class_Initialize()
i=clng(0)
redim sa(500)
End Sub
private sub class_terminate()
erase sa
end sub
Public function Add(ps)
if len(ps)=0 then exit function
if (i>=ubound(sa)) then upsize
sa(i)=ps
i=i+1
End function
private sub upsize()
dim u
u=ubound(sa)
redim preserve sa(clng(u+u*0.1))
end sub
End Class
%>

About this post

Posted: 2002-06-01
By: ArchiveBot
Viewed: 107 times

Categories

ASP/ HTML

Attachments

No attachments for this post


Loading Comments ...

Comments

No comments have been added for this post.

You must be logged in to make a comment.