Individualize NameHashSet Hashing & Revisit #709 (#740)

* Make mac/win lookups lowercase'd

* Revert #709 & 81042cc

* Adjust HashPolicy implementation across sourcemod

Basically, in order to implement our own (actual) hash policy in
`PluginSys.h`, we needed to remove the blanket implementation of `hash`
that was used before. Now, each policy must implement `hash` along with
`matches` in order to be used with `NameHashSet`. While this does force
us to change every implementation of policies across the entirety of
sourcemod, it allows core to use flexible implementations of `hash`.

* Remove logic duplication

* Improve lowercase checks
This commit is contained in:
Michael Flaherty
2018-07-10 17:38:40 -04:00
committed by Nicholas Hastings
parent daee19d502
commit aaac0b9eb2
15 changed files with 99 additions and 40 deletions
+7 -5
View File
@@ -48,10 +48,12 @@
namespace SourceMod
{
// The HashPolicy type must have this method:
// The HashPolicy type must have these methods:
// static bool matches(const char *key, const T &value);
// static uint32_t hash(const CharsAndLength &key);
//
// Depending on what lookup types are used.
// Depending on what lookup types are used, and how hashing should be done.
// Most of the time, key hashing will just call the key's hash() method.
//
// If these members are available on T, then the HashPolicy type can be left
// default. It is okay to use |T *|, the functions will still be looked up
@@ -69,7 +71,7 @@ class NameHashSet : public ke::SystemAllocatorPolicy
static uint32_t hash(const CharsAndLength &key)
{
return key.hash();
return KeyPolicyType::hash(key);
}
static bool matches(const CharsAndLength &key, const KeyType &value)
@@ -85,9 +87,9 @@ class NameHashSet : public ke::SystemAllocatorPolicy
{
typedef KeyType *Payload;
static uint32_t hash(const detail::CharsAndLength &key)
static uint32_t hash(const CharsAndLength &key)
{
return key.hash();
return KeyType::hash(key);
}
static bool matches(const CharsAndLength &key, const KeyType *value)