Some strings are always indices.

This saves 4 bytes.
This commit is contained in:
Bartosz Taudul 2017-11-14 23:37:44 +01:00 committed by Bartosz Taudul
parent 7da59a55cc
commit 7187e1e5f5
3 changed files with 21 additions and 2 deletions

View File

@ -39,6 +39,18 @@ struct StringRef
uint8_t active : 1; uint8_t active : 1;
}; };
struct StringIdx
{
StringIdx() : active( 0 ) {}
StringIdx( uint32_t idx )
: idx( idx )
, active( 1 )
{}
uint32_t idx : 31;
uint32_t active : 1;
};
struct SourceLocation struct SourceLocation
{ {
StringRef name; StringRef name;
@ -59,7 +71,7 @@ struct ZoneEvent
int8_t cpu_start; int8_t cpu_start;
int8_t cpu_end; int8_t cpu_end;
StringRef text; StringIdx text;
Vector<ZoneEvent*> child; Vector<ZoneEvent*> child;
}; };

View File

@ -686,7 +686,7 @@ void View::ProcessZoneText( const QueueZoneText& ev )
auto it = m_pendingCustomStrings.find( ev.text ); auto it = m_pendingCustomStrings.find( ev.text );
assert( it != m_pendingCustomStrings.end() ); assert( it != m_pendingCustomStrings.end() );
m_lock.lock(); m_lock.lock();
zone->text = StringRef( StringRef::Idx, it->second.idx ); zone->text = StringIdx( it->second.idx );
m_lock.unlock(); m_lock.unlock();
m_pendingCustomStrings.erase( it ); m_pendingCustomStrings.erase( it );
} }
@ -1403,6 +1403,12 @@ const char* View::GetString( const StringRef& ref ) const
} }
} }
const char* View::GetString( const StringIdx& idx ) const
{
assert( idx.active );
return m_stringData[idx.idx];
}
const char* View::GetThreadString( uint64_t id ) const const char* View::GetThreadString( uint64_t id ) const
{ {
const auto it = m_threadNames.find( id ); const auto it = m_threadNames.find( id );

View File

@ -109,6 +109,7 @@ private:
int64_t GetZoneEnd( const GpuEvent& ev ) const; int64_t GetZoneEnd( const GpuEvent& ev ) const;
const char* GetString( uint64_t ptr ) const; const char* GetString( uint64_t ptr ) const;
const char* GetString( const StringRef& ref ) const; const char* GetString( const StringRef& ref ) const;
const char* GetString( const StringIdx& idx ) const;
const char* GetThreadString( uint64_t id ) const; const char* GetThreadString( uint64_t id ) const;
const SourceLocation& GetSourceLocation( int32_t srcloc ) const; const SourceLocation& GetSourceLocation( int32_t srcloc ) const;