The reason why I dont want to do it per-member is that if I do this:
hash = hash(member1) ? hash(member2);
I dont know what operation to use to combine the hashes in place of '?', and I dont know if doing this is going to weaken the hash and introduce more collisions or such. And the hash functions themselves probably run faster if they have a contiguous string of bytes instead of doing it one member at a time.
(I could do hash = hash(hash(member1) ? hash(member2)) but then I wont get 6000 FPS due to the extra hash *sadface*)
I changed to basically the following:
std::array<ui8, sizeof(member1) + sizeof(member2)> bytes;
*copy members to bytes array*
return murmurhash3(bytes);
And it seems to run faster than what I had before (return hash(member1) + hash(member2)) which is surprising since the implementation of std hash seemed trivial (on msvc) compared to murmurhash3. But I cant be sure why its faster (less collisions?).
The copying adds overhead but it doesnt seem to be noticeable for objects this small. If I need bigger objects, Ill probably just split the murmurhash3 func into multiple functions so I have more control over where the data comes from... (currently it just takes a void* and length :/)
So from what I gather:
-I should use murmurhash3 because it happens to be marginally faster on msvc for now and I wont be reliant on the implementation to choose a good hash algo
-I should modify it to avoid the copying step currently required (it works on 128 bit blocks and has a 'finalizing' operation so its not as simple as just call it multiple times), basically either make it into a class or write a combineHash method