Bug 1379312 - Improve nsAssignment's hashing algorithm by redoing it on top of mozilla::HashGeneric(); r=mystor

This commit is contained in:
Ehsan Akhgari 2017-07-07 19:22:06 -04:00
parent 9ab7e769c8
commit e535476a59

View File

@ -29,6 +29,7 @@
#define nsRuleNetwork_h__
#include "mozilla/Attributes.h"
#include "mozilla/HashFunctions.h"
#include "nsCOMPtr.h"
#include "nsCOMArray.h"
#include "nsIAtom.h"
@ -208,9 +209,8 @@ public:
return mVariable != aAssignment.mVariable || mValue != aAssignment.mValue; }
PLHashNumber Hash() const {
// XXX I have no idea if this hashing function is good or not // XXX change this
PLHashNumber temp = PLHashNumber(NS_PTR_TO_INT32(mValue.get())) >> 2; // strip alignment bits
return (temp & 0xffff) | NS_PTR_TO_INT32(mVariable.get()); }
using mozilla::HashGeneric;
return HashGeneric(mVariable.get()) ^ HashGeneric(mValue.get()); }
};