mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-26 16:04:34 +00:00
Preserve string length in string map.
This commit is contained in:
parent
17e1894034
commit
08642d034b
@ -2114,7 +2114,8 @@ StringLocation Worker::StoreString( char* str, size_t sz )
|
||||
StringLocation ret;
|
||||
const char backup = str[sz];
|
||||
str[sz] = '\0';
|
||||
auto sit = m_data.stringMap.find( str );
|
||||
charutil::StringKey key = { str, sz };
|
||||
auto sit = m_data.stringMap.find( key );
|
||||
if( sit == m_data.stringMap.end() )
|
||||
{
|
||||
auto ptr = m_slab.Alloc<char>( sz+1 );
|
||||
@ -2122,12 +2123,12 @@ StringLocation Worker::StoreString( char* str, size_t sz )
|
||||
ptr[sz] = '\0';
|
||||
ret.ptr = ptr;
|
||||
ret.idx = m_data.stringData.size();
|
||||
m_data.stringMap.emplace( ptr, m_data.stringData.size() );
|
||||
m_data.stringMap.emplace( charutil::StringKey { ptr, sz }, m_data.stringData.size() );
|
||||
m_data.stringData.push_back( ptr );
|
||||
}
|
||||
else
|
||||
{
|
||||
ret.ptr = sit->first;
|
||||
ret.ptr = sit->first.ptr;
|
||||
ret.idx = sit->second;
|
||||
}
|
||||
str[sz] = backup;
|
||||
|
@ -118,7 +118,7 @@ private:
|
||||
|
||||
flat_hash_map<uint64_t, const char*, nohash<uint64_t>> strings;
|
||||
Vector<const char*> stringData;
|
||||
flat_hash_map<const char*, uint32_t, charutil::HasherPOT, charutil::Comparator> stringMap;
|
||||
flat_hash_map<charutil::StringKey, uint32_t, charutil::StringKey::HasherPOT, charutil::StringKey::Comparator> stringMap;
|
||||
flat_hash_map<uint64_t, const char*, nohash<uint64_t>> threadNames;
|
||||
|
||||
flat_hash_map<uint64_t, SourceLocation, nohash<uint64_t>> sourceLocation;
|
||||
|
Loading…
Reference in New Issue
Block a user