Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Fast Byte Array To String Array conversion

Status
Not open for further replies.

devilman0

IS-IT--Management
Nov 14, 2002
257
US
This one has me stuck in the dark....
A bit of background: I am working on an app that opens deflated (compressed) logs. Everything works, except, the logs can be a few mb.
The problem i am running into is that to convert the byte data (1024 chunks) into readable strings i do this:
Code:
For i = 0 To bytesOut - 1
    StrOut(LngTotalOut + i) = Chr(outBuffer(i))
    LngTotalOut = LngTotalOut + bytesOut
Next i
Like i said, this works, but is increadably slow, any suggestions?

Thanks,
James
[afro][mad]
"Make it idiot-proof and someone will make a better idiot." ~bumper sticker
 

Well part of the problem it seems is that each chunck of 1024 is appended to a single array that gets larger and larger while the array of bytes stays small. This means that after while you will slow down as it needs to allocate more memory to the string array and depending upon the system you could be slowing down even further by the OS needing to use the swap file.

Now I cannot find it but perhaps someone will remember the thread that had copymemory and copying arrays fast and will be able to point you to it (or you could search for it).

Good Luck

 
Yes, string-concatenation in VB is very slow, getting slower the longer the string gets.
Have a loook at:
A guy called Martijn posted an incredible efficient class module. I'm sure that everybody who ever tested his code will include it in every VB-project he will work on.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top