ich habe noch einmal einen kleinen Test gemacht und das ganze noch etwas
schneller bekommen... ;)
Join: 275 ticks (String size is 1024000)
Private Function StringToHex(src as string, separator as string) As string
#pragma BackgroundTasks false
dim L, v as integer
dim s() as string
L = LenB(src)
for n as integer = 1 to L
v = AscB(MidB(src, n, 1))
s.Append RightB("00"+Hex(v),2)
next
return Join(s, separator)
End Function
Join/check: 198 ticks (String size is 1024000)
Private Function StringToHex(src as string, separator as string) As string
#pragma BackgroundTasks false
dim L as integer
dim s() as string
L = LenB(src)
for n as integer = 1 to L
dim v as String = Hex(AscB(MidB(src, n, 1)))
if lenB(v)=1 then
s.Append RightB("00"+v,2)
else
s.Append v
end
next
return Join(s, separator)
End Function
Memoryblock: 162 ticks (String size is 1024000)
Private Function StringToHex(src as string, separator as string) As string
#pragma BackgroundTasks false
dim L as integer = LenB(src)
dim mb As MemoryBlock = NewMemoryBlock(L)
mb.StringValue(0, L) = src
dim s() as String
for n as integer = 0 to L-1
dim b As byte = mb.Byte(n)
if b<16 then
s.Append "0"+Hex(b)
else
s.Append Hex(b)
end
next
return Join(s, separator)
End Function
Tom