I have a struct with some properties (like int A1
, int A2
,...). I store a list of struct as binary in a file.
Now, I'm reading the bytes from file using binary reader into Buffer
and I want to apply a filter based on the struct's properties (like .A1 = 100 & .A2 = 12
).
The performance is very important in my scenario, so I convert the filter criteria to byte array (Filter
) and then I want to mask Buffer
with Filter
. If the result of masking is equal to Filter
, the Buffer
will be converted to the struct.
The question: What is the fastest way to mask and compare two byte arrays?
Update: The Buffer
size is more than 256 bytes. I'm wondering if there is a better way rather than iterating in each byte of Buffer
and Filter
.