1
0
mirror of https://github.com/wolfpld/tracy synced 2025-04-29 04:23:51 +00:00

Add specialized string key for hash map.

This commit is contained in:
Bartosz Taudul 2019-02-12 20:23:01 +01:00
parent ec37f59c14
commit 17e1894034

View File

@ -69,6 +69,33 @@ struct LessComparator
}
};
struct StringKey
{
const char* ptr;
size_t sz;
struct Hasher
{
size_t operator()( const StringKey& key ) const
{
return hash( key.ptr, key.sz );
}
};
struct HasherPOT : public Hasher
{
typedef tracy::power_of_two_hash_policy hash_policy;
};
struct Comparator
{
bool operator()( const StringKey& lhs, const StringKey& rhs ) const
{
return lhs.sz == rhs.sz && memcmp( lhs.ptr, rhs.ptr, lhs.sz ) == 0;
}
};
};
}
}