Valhalla Legends Archive

Programming => General Programming => Visual Basic Programming => Topic started by: o.OV on February 04, 2004, 11:25 AM

Title: VB's native Replace function
Post by: o.OV on February 04, 2004, 11:25 AM
@_<
Is it just me.. or is VB's Replace function really really slow..

That is.. if there is padding or it is same length strings.



Public Declare Function GetTickCount Lib "kernel32.dll" () As Long

Public Sub test3()

   Dim t As Long, x As Long, test As String, faketest As String, something As Long
   test = Space$(100000)
   theword = "test"
   replacer = "fake"
   something = 1
   
   For x = 0 To (100000 / 4) - 1
       Mid$(test, (x * 4) + 1, 4) = theword
   Next x
   
   faketest = test
   t = GetTickCount
   Do
       something = InStr(something, faketest, theword)
       If something Then
           Mid$(faketest, something, 4) = replacer
       End If
   Loop While something
   MsgBox "instr: " & GetTickCount - t
   
   faketest = test
   t = GetTickCount
   faketest = Replace(faketest, theword, replacer)
   MsgBox "replace: " & GetTickCount - t
   
End Sub

Title: Re:VB's native Replace function
Post by: TheMinistered on February 04, 2004, 12:36 PM
So, write your own in assembly that complies to the way visual basic passes/returns data and i'll implement it into vb natively.