VB.net字节数组搜索

我正在开发一个简单的病毒扫描程序,我正在寻找以下功能的速度改进:
Public Function FindAInB(ByRef byteArrayA() As Byte, ByRef byteArrayB() As Byte) As Integer
    Dim startmatch As Integer = -1
    Dim offsetA As Integer = 0
    Dim offsetB As Integer = 0

    For offsetB = 0 To byteArrayB.Length - 1
        If byteArrayA(offsetA) = byteArrayB(offsetB) Then
            If startmatch = -1 AndAlso offsetB < byteArrayB.Length - 8 Then
                startmatch = offsetB
            End If
            offsetA += 1
            If offsetA = byteArrayA.Length Then
                Exit For
            End If
        Else
            offsetA = 0
            startmatch = -1
        End If
    Next
    Return startmatch
End Function
我需要它是turbo快速,因为它在所选文件的字节中搜索大约7800字节数组。有点难以解释但是上面的代码是否有替代方法或加速它的方法? 提前致谢!     
已邀请:
您应该查看像Boyer-Moore这样的字符串搜索算法。 虽然您实际上并不是在搜索文本,但是您在较大的字节字符串中搜索字节串,因此这些类型的算法可能会有很大帮助。     

要回复问题请先登录注册