Skip to content

Commit

Permalink
Fix qmake hash function to use XOR
Browse files Browse the repository at this point in the history
Use XOR instead of OR in order to avoid saturating all bits when computing the
hash value.

Change-Id: I50b1a044eb827239dae1c04732ca6a065f6233b4
Reviewed-by: Andreas Holzammer <[email protected]>
Reviewed-by: Oswald Buddenhagen <[email protected]>
  • Loading branch information
Rafael Roquetto authored and Qt by Nokia committed Jul 25, 2012
1 parent 4677cf3 commit 3a27d4b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions qmake/cachekeys.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ struct FixStringCacheKey
}
inline uint hashCode() const {
if(!hash)
hash = qHash(string) | qHash(flags) /*| qHash(pwd)*/;
hash = qHash(string) ^ qHash(flags) /*^ qHash(pwd)*/;
return hash;
}
};
Expand All @@ -98,7 +98,7 @@ struct FileInfoCacheKey
}
inline uint hashCode() const {
if(!hash)
hash = qHash(file) /*| qHash(pwd)*/;
hash = qHash(file) /*^ qHash(pwd)*/;
return hash;
}
inline bool isRelativePath(const QString &file) {
Expand Down
2 changes: 1 addition & 1 deletion qmake/generators/makefile.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ struct ReplaceExtraCompilerCacheKey
bool operator==(const ReplaceExtraCompilerCacheKey &f) const;
inline uint hashCode() const {
if(!hash)
hash = qHash(var) | qHash(in) | qHash(out) /*| qHash(pwd)*/;
hash = qHash(var) ^ qHash(in) ^ qHash(out) /*^ qHash(pwd)*/;
return hash;
}
};
Expand Down

0 comments on commit 3a27d4b

Please sign in to comment.