Fix TinyHashMap to use generic hash_type instead of hash_t

TinyHashMap used hash_t(key) to generate hashcode. This
would not work for 64-bit pointers as hash_t is declared as
an uint32_t.

Replaced the hash_t(key) call to more generic android::hash_type(key).
This function is a template function declared in TypeHelpers.h and
has a version available for all data types including pointers.

Change-Id: I612cf18b49ca7c30b63f9d6938df68fed7d80d08
Signed-off-by: Ashok Bhat <ashok.bhat@arm.com>
This commit is contained in:
Ashok Bhat
2014-02-07 16:31:41 +00:00
committed by David Butcher
parent 449273e2d5
commit e9bea2a182

View File

@@ -24,8 +24,6 @@ namespace uirenderer {
/**
* A very simple hash map that doesn't allow duplicate keys, overwriting the older entry.
*
* Currently, expects simple keys that are handled by hash_t()
*/
template <typename TKey, typename TValue>
class TinyHashMap {
@@ -36,7 +34,7 @@ public:
* Puts an entry in the hash, removing any existing entry with the same key
*/
void put(TKey key, TValue value) {
hash_t hash = hash_t(key);
hash_t hash = android::hash_type(key);
ssize_t index = mTable.find(-1, hash, key);
if (index != -1) {
@@ -51,7 +49,7 @@ public:
* Return true if key is in the map, in which case stores the value in the output ref
*/
bool get(TKey key, TValue& outValue) {
hash_t hash = hash_t(key);
hash_t hash = android::hash_type(key);
ssize_t index = mTable.find(-1, hash, key);
if (index == -1) {
return false;