Common storage for plot names.

This commit is contained in:
Bartosz Taudul 2017-11-10 19:41:37 +01:00
parent 5ec3ccd595
commit 96ce90c6ed
2 changed files with 9 additions and 7 deletions

View File

@ -541,7 +541,7 @@ void View::DispatchProcess( const QueueItem& ev, char*& ptr )
AddThreadString( ev.stringTransfer.ptr, ptr, sz ); AddThreadString( ev.stringTransfer.ptr, ptr, sz );
break; break;
case QueueType::PlotName: case QueueType::PlotName:
HandlePlotName( ev.stringTransfer.ptr, std::string( ptr, ptr+sz ) ); HandlePlotName( ev.stringTransfer.ptr, ptr, sz );
break; break;
case QueueType::MessageData: case QueueType::MessageData:
AddMessageData( ev.stringTransfer.ptr, ptr, sz ); AddMessageData( ev.stringTransfer.ptr, ptr, sz );
@ -1209,20 +1209,22 @@ void View::InsertPlot( PlotData* plot, PlotItem* item )
} }
} }
void View::HandlePlotName( uint64_t name, std::string&& str ) void View::HandlePlotName( uint64_t name, char* str, size_t sz )
{ {
auto pit = m_pendingPlots.find( name ); auto pit = m_pendingPlots.find( name );
assert( pit != m_pendingPlots.end() ); assert( pit != m_pendingPlots.end() );
auto it = m_plotRev.find( str ); const auto sl = StoreString( str, sz );
auto it = m_plotRev.find( sl.ptr );
if( it == m_plotRev.end() ) if( it == m_plotRev.end() )
{ {
const auto idx = m_plots.size(); const auto idx = m_plots.size();
m_plotMap.emplace( name, idx ); m_plotMap.emplace( name, idx );
m_plotRev.emplace( str, idx ); m_plotRev.emplace( sl.ptr, idx );
std::lock_guard<std::mutex> lock( m_lock ); std::lock_guard<std::mutex> lock( m_lock );
m_plots.push_back( pit->second ); m_plots.push_back( pit->second );
//m_strings.emplace( name, std::move( str ) ); m_strings.emplace( name, sl.ptr );
} }
else else
{ {

View File

@ -173,7 +173,7 @@ private:
void InsertPlot( PlotData* plot, int64_t time, double val ); void InsertPlot( PlotData* plot, int64_t time, double val );
void InsertPlot( PlotData* plot, PlotItem* item ); void InsertPlot( PlotData* plot, PlotItem* item );
void HandlePlotName( uint64_t name, std::string&& str ); void HandlePlotName( uint64_t name, char* str, size_t sz );
void HandlePostponedPlots(); void HandlePostponedPlots();
int64_t GetFrameTime( size_t idx ) const; int64_t GetFrameTime( size_t idx ) const;
@ -259,7 +259,7 @@ private:
std::unordered_map<uint64_t, ZoneEvent*> m_pendingCustomStrings; std::unordered_map<uint64_t, ZoneEvent*> m_pendingCustomStrings;
std::unordered_map<uint64_t, uint32_t> m_threadMap; std::unordered_map<uint64_t, uint32_t> m_threadMap;
std::unordered_map<uint64_t, uint32_t> m_plotMap; std::unordered_map<uint64_t, uint32_t> m_plotMap;
std::unordered_map<std::string, uint32_t> m_plotRev; std::unordered_map<const char*, uint32_t, charutil::Hasher, charutil::Comparator> m_plotRev;
std::unordered_map<uint64_t, PlotData*> m_pendingPlots; std::unordered_map<uint64_t, PlotData*> m_pendingPlots;
std::unordered_map<uint64_t, MessagePending> m_pendingMessages; std::unordered_map<uint64_t, MessagePending> m_pendingMessages;
std::unordered_map<uint64_t, uint32_t> m_sourceLocationShrink; std::unordered_map<uint64_t, uint32_t> m_sourceLocationShrink;