Individualize NameHashSet Hashing & Revisit #709 (#740) (1.9-dev) (#866)

This is a clone of #740, but without the amtl ke::AString lowercase which was implemented in a new version of amtl that 1.9-dev isn't pinned to. Updating this pin and moving fixes is beyond what should go in 1.9, and this fixes a annoying and user-impactful bug with reload/unloading plugins on windows.

Currently in 1.9, once a plugin is loaded into the pluginsys, they must be used with lowercase characters *only*, since pr #709 ignorantly modified their names. 

```
// test.smx exists in /plugins/
sm plugins load TEST.smx // successful
sm plugins unload TEST.smx // TEST.smx not found, it's actually test.smx
```

This pr fixes that error by converting *all* lookups, not just loads.
This commit is contained in:
Michael Flaherty
2018-08-11 13:37:05 +01:00
committed by Asher Baker
parent c6303d1ec3
commit dd456dcb19
15 changed files with 117 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)