diff options
author | Bartosz Taudul <wolf.pld@gmail.com> | 2019-02-12 22:23:01 +0300 |
---|---|---|
committer | Bartosz Taudul <wolf.pld@gmail.com> | 2019-02-13 00:11:15 +0300 |
commit | 17e18940349acc4eb791a6856a578271ee0d119a (patch) | |
tree | 45eb41b3a6f7a8422edaf6b4fa6f2d4e361f776a /server/TracyCharUtil.hpp | |
parent | ec37f59c149ae6f8f5d6c071842aae95a98c24c4 (diff) |
Add specialized string key for hash map.
Diffstat (limited to 'server/TracyCharUtil.hpp')
-rw-r--r-- | server/TracyCharUtil.hpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/server/TracyCharUtil.hpp b/server/TracyCharUtil.hpp index 8dd777fd..8b09f3bf 100644 --- a/server/TracyCharUtil.hpp +++ b/server/TracyCharUtil.hpp @@ -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; + } + }; +}; + } } |