mirror of
https://github.com/wolfpld/tracy
synced 2025-05-01 13:13:53 +00:00
Add specialized string key for hash map.
This commit is contained in:
parent
ec37f59c14
commit
17e1894034
@ -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;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user