Updated code.
VB Code:
Public Sub bArrRemoveDuplicate(ByRef ByteArray() As Byte) Dim LowBound As Long, UpBound As Long Dim TempArray() As Byte, TempByte As Byte, Cur As Long Dim A As Long, B As Long 'check for empty array If (Not ByteArray) = True Then Exit Sub 'we need these often LowBound = LBound(ByteArray) UpBound = UBound(ByteArray) 'reserve check buffer ReDim TempArray(LowBound To UpBound) 'set first item Cur = LowBound TempArray(Cur) = ByteArray(LowBound) 'loop through all items For A = LowBound + 1 To UpBound TempByte = ByteArray(A) 'make a comparison against all items For B = LowBound To Cur 'if is a duplicate, exit array If (TempArray(B) Xor TempByte) = 0 Then Exit For Next B 'check if the loop was exited: add new item to check buffer if not If B > Cur Then Cur = B: TempArray(Cur) = ByteArray(A) Next A 'fix size ReDim Preserve TempArray(LowBound To Cur) 'copy ByteArray = TempArray End Sub
Noticed a silly thing I forgot to optimize. Now it is only 1.3 times the speed of the ASM code.




Reply With Quote