mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Switched from old hashing functions to use Bob Jenkins' hash routine
- If the underlying type is contiguous, FixedList hashes its storage directly. - Drop labelPairHash (non-commutative) from fvMeshDistribute since FixedList::Hash does the right thing anyhow. - Hash<edge> specialization is commutative, without multiplication. - Hash<triFace> specialization kept multiplication (but now uLabel). There's not much point optimizing it, since it's not used much anyhow. Misc. changes - added StaticAssert to NamedEnum.H - label.H / uLabel.H : define FOAM_LABEL_MAX, FOAM_ULABEL_MAX with the values finally used for the storage. These can be useful for pre-processor checks elsewhere (although I stopped needing them in the meantime).
This commit is contained in:
@ -47,6 +47,7 @@ SourceFiles
|
||||
#define string_H
|
||||
|
||||
#include "char.H"
|
||||
#include "Hasher.H"
|
||||
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
@ -92,7 +93,7 @@ public:
|
||||
hash()
|
||||
{}
|
||||
|
||||
inline unsigned operator()(const string&) const;
|
||||
inline unsigned operator()(const string&, unsigned seed = 0) const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -198,19 +198,11 @@ inline Foam::string Foam::string::operator()(const size_type n) const
|
||||
|
||||
inline unsigned Foam::string::hash::operator()
|
||||
(
|
||||
const string& key
|
||||
const string& key,
|
||||
unsigned seed
|
||||
) const
|
||||
{
|
||||
const size_type len = key.length();
|
||||
const char *data = key.data();
|
||||
|
||||
register unsigned val = 0;
|
||||
for (register size_type i=0; i < len; ++data, ++i)
|
||||
{
|
||||
val = (val << 1) ^ *data;
|
||||
}
|
||||
|
||||
return val;
|
||||
return Hasher(key.data(), key.size(), seed);
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
Reference in New Issue
Block a user