Fast byte[] searching

I managed to decrease the size of both arrays:

SortedDictionary<int,byte[]> builder => from 191k to 130k aprox. (removed null bytes[])
List<byte[]> movPush => 13k (if I recall correctly) (if there is too much repeated numbers, like: 68 00 00 00 01 -> probably not a PUSH Im interested in, so I delete if anyRepetedNumbers >= 2

But it is still too slow.
I am doing this way:

Code:
foreach element in builder
{
var stringOffset = element.Key;
// now I generate the PUSH code for the given offset and search in the entire movPush List, if it is found, then I add it to my final dictionary.
}

I read that foreach loop is slow compared to for loop, but I am afraid I can't use for in this case, because my Dictionary indexes are not 0,1,2,3,4 but instead, they are the offset where the byte[] (string) was found.
 
I managed to decrease the size of both arrays:

SortedDictionary<int,byte[]> builder => from 191k to 130k aprox. (removed null bytes[])
List<byte[]> movPush => 13k (if I recall correctly) (if there is too much repeated numbers, like: 68 00 00 00 01 -> probably not a PUSH Im interested in, so I delete if anyRepetedNumbers >= 2

But it is still too slow.
I am doing this way:

Code:
foreach element in builder
{
var stringOffset = element.Key;
// now I generate the PUSH code for the given offset and search in the entire movPush List, if it is found, then I add it to my final dictionary.
}

I read that foreach loop is slow compared to for loop, but I am afraid I can't use for in this case, because my Dictionary indexes are not 0,1,2,3,4 but instead, they are the offset where the byte[] (string) was found.
Which loop you use has no difference whatsoever. Focus on the big numbers here: how many elements in each list, how exactly you query for a match and such things. It's unlikely the algorithm gets any significant boost from such minor optimizations as removing cases with repeated numbers, which is bad anyhow if you're not sure if you're filtering out possibly useful data. Why do you ignore such cases at random, anyway? You could just as easily check the offsets dictionary for a match and be sure if it's needed or not. If you want more insight on any possible bottlenecks in your algorithm I'll be glad to help but I'll probably need to see more of the code exactly as it is.
 
Back