From 08642d034b4d94733d225fe1eb7c3c1cbedf33cd Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Tue, 12 Feb 2019 20:23:14 +0100 Subject: [PATCH] Preserve string length in string map. --- server/TracyWorker.cpp | 7 ++++--- server/TracyWorker.hpp | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/server/TracyWorker.cpp b/server/TracyWorker.cpp index df23b67c..cbaa34e5 100644 --- a/server/TracyWorker.cpp +++ b/server/TracyWorker.cpp @@ -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( 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; diff --git a/server/TracyWorker.hpp b/server/TracyWorker.hpp index 40fbfa93..f925b6bd 100644 --- a/server/TracyWorker.hpp +++ b/server/TracyWorker.hpp @@ -118,7 +118,7 @@ private: flat_hash_map> strings; Vector stringData; - flat_hash_map stringMap; + flat_hash_map stringMap; flat_hash_map> threadNames; flat_hash_map> sourceLocation;