What is a good solution to the inefficiency of the & operator?

Source: Internet
Author: User
Solve | problem | calculation everyone look.

We know that "&" is faster than using "+" number. Because "+" to the character-channeling variable to do type judgment and conversion.


I didn't come up with any good ideas at the time. Only two times the "&" operation was opened, the speed was raised one times. Still can't solve the problem.
The result is: For I 1 to 5000, I add in the form of a character. Use & operation, to 600-800ms

Now try this one below. A Cstrcat class was built.

<%
Pageexetime1=timer * 1000 ' clock start

Set sc=new Cstrcat
For I=0 to 5000
Sc.add I
Next
Response.Write Sc.value

' End of Time '
Response.Write ", Processed time:" & Fix (ABS (CDBL (Timer) *1000-pageexetime1)) & "Ms</font></p>"
%>


<%
Class Cstrcat ' This is the beginning of classes.
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
%>



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.