mirror of
https://github.com/wolfpld/tracy
synced 2025-05-03 14:03:52 +00:00
Store custom strings in an addressable vector.
This commit is contained in:
parent
97fad073d9
commit
44ee282b6e
@ -243,7 +243,8 @@ View::View( FileRead& f )
|
|||||||
auto dst = m_slab.Alloc<char>( ssz+1 );
|
auto dst = m_slab.Alloc<char>( ssz+1 );
|
||||||
f.Read( dst, ssz );
|
f.Read( dst, ssz );
|
||||||
dst[ssz] = '\0';
|
dst[ssz] = '\0';
|
||||||
m_customStrings.emplace( dst );
|
m_customStringMap.emplace( dst, m_customStringData.size() );
|
||||||
|
m_customStringData.push_back( dst );
|
||||||
stringMap.emplace( ptr, dst );
|
stringMap.emplace( ptr, dst );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -980,19 +981,20 @@ void View::AddCustomString( uint64_t ptr, std::string&& str )
|
|||||||
auto pit = m_pendingCustomStrings.find( ptr );
|
auto pit = m_pendingCustomStrings.find( ptr );
|
||||||
assert( pit != m_pendingCustomStrings.end() );
|
assert( pit != m_pendingCustomStrings.end() );
|
||||||
std::unique_lock<std::mutex> lock( m_lock );
|
std::unique_lock<std::mutex> lock( m_lock );
|
||||||
auto sit = m_customStrings.find( str.c_str() );
|
auto sit = m_customStringMap.find( str.c_str() );
|
||||||
if( sit == m_customStrings.end() )
|
if( sit == m_customStringMap.end() )
|
||||||
{
|
{
|
||||||
const auto sz = str.size();
|
const auto sz = str.size();
|
||||||
auto ptr = m_slab.Alloc<char>( sz+1 );
|
auto ptr = m_slab.Alloc<char>( sz+1 );
|
||||||
memcpy( ptr, str.c_str(), sz );
|
memcpy( ptr, str.c_str(), sz );
|
||||||
ptr[sz] = '\0';
|
ptr[sz] = '\0';
|
||||||
GetTextData( *pit->second )->userText = ptr;
|
GetTextData( *pit->second )->userText = ptr;
|
||||||
m_customStrings.emplace( ptr );
|
m_customStringMap.emplace( ptr, m_customStringData.size() );
|
||||||
|
m_customStringData.push_back( ptr );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GetTextData( *pit->second )->userText = *sit;
|
GetTextData( *pit->second )->userText = sit->first;
|
||||||
}
|
}
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
m_pendingCustomStrings.erase( pit );
|
m_pendingCustomStrings.erase( pit );
|
||||||
@ -3303,9 +3305,9 @@ void View::Write( FileWrite& f )
|
|||||||
f.Write( v.second.c_str(), v.second.size() );
|
f.Write( v.second.c_str(), v.second.size() );
|
||||||
}
|
}
|
||||||
|
|
||||||
sz = m_customStrings.size();
|
sz = m_customStringData.size();
|
||||||
f.Write( &sz, sizeof( sz ) );
|
f.Write( &sz, sizeof( sz ) );
|
||||||
for( auto& v : m_customStrings )
|
for( auto& v : m_customStringData )
|
||||||
{
|
{
|
||||||
uint64_t ptr = (uint64_t)v;
|
uint64_t ptr = (uint64_t)v;
|
||||||
f.Write( &ptr, sizeof( ptr ) );
|
f.Write( &ptr, sizeof( ptr ) );
|
||||||
|
@ -233,12 +233,14 @@ private:
|
|||||||
Vector<SourceLocation*> m_sourceLocationPayload;
|
Vector<SourceLocation*> m_sourceLocationPayload;
|
||||||
std::unordered_map<uint64_t, std::string> m_strings;
|
std::unordered_map<uint64_t, std::string> m_strings;
|
||||||
std::unordered_map<uint64_t, std::string> m_threadNames;
|
std::unordered_map<uint64_t, std::string> m_threadNames;
|
||||||
std::unordered_set<const char*, charutil::Hasher, charutil::Comparator> m_customStrings;
|
|
||||||
std::unordered_map<uint64_t, SourceLocation> m_sourceLocation;
|
std::unordered_map<uint64_t, SourceLocation> m_sourceLocation;
|
||||||
std::vector<uint64_t> m_sourceLocationExpand;
|
std::vector<uint64_t> m_sourceLocationExpand;
|
||||||
std::map<uint32_t, LockMap> m_lockMap;
|
std::map<uint32_t, LockMap> m_lockMap;
|
||||||
uint64_t m_zonesCnt;
|
uint64_t m_zonesCnt;
|
||||||
|
|
||||||
|
Vector<const char*> m_customStringData;
|
||||||
|
std::unordered_map<const char*, uint32_t, charutil::Hasher, charutil::Comparator> m_customStringMap;
|
||||||
|
|
||||||
std::mutex m_mbpslock;
|
std::mutex m_mbpslock;
|
||||||
std::vector<float> m_mbps;
|
std::vector<float> m_mbps;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user