mirror of
https://github.com/wolfpld/tracy
synced 2025-05-03 14:03:52 +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;
|
StringLocation ret;
|
||||||
const char backup = str[sz];
|
const char backup = str[sz];
|
||||||
str[sz] = '\0';
|
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() )
|
if( sit == m_data.stringMap.end() )
|
||||||
{
|
{
|
||||||
auto ptr = m_slab.Alloc<char>( sz+1 );
|
auto ptr = m_slab.Alloc<char>( sz+1 );
|
||||||
@ -2122,12 +2123,12 @@ StringLocation Worker::StoreString( char* str, size_t sz )
|
|||||||
ptr[sz] = '\0';
|
ptr[sz] = '\0';
|
||||||
ret.ptr = ptr;
|
ret.ptr = ptr;
|
||||||
ret.idx = m_data.stringData.size();
|
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 );
|
m_data.stringData.push_back( ptr );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ret.ptr = sit->first;
|
ret.ptr = sit->first.ptr;
|
||||||
ret.idx = sit->second;
|
ret.idx = sit->second;
|
||||||
}
|
}
|
||||||
str[sz] = backup;
|
str[sz] = backup;
|
||||||
|
@ -118,7 +118,7 @@ private:
|
|||||||
|
|
||||||
flat_hash_map<uint64_t, const char*, nohash<uint64_t>> strings;
|
flat_hash_map<uint64_t, const char*, nohash<uint64_t>> strings;
|
||||||
Vector<const char*> stringData;
|
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, const char*, nohash<uint64_t>> threadNames;
|
||||||
|
|
||||||
flat_hash_map<uint64_t, SourceLocation, nohash<uint64_t>> sourceLocation;
|
flat_hash_map<uint64_t, SourceLocation, nohash<uint64_t>> sourceLocation;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user