1
0
mirror of https://github.com/wolfpld/tracy.git synced 2025-03-20 07:40:02 +08:00

Don't read memory when setting values.

This commit is contained in:
Bartosz Taudul
2019-10-24 23:03:13 +02:00
parent c9da5f1474
commit 45332fd837
2 changed files with 25 additions and 24 deletions
+3 -2
View File
@@ -6,6 +6,7 @@
#include <shared_mutex>
#include <stdexcept>
#include <string>
#include <string.h>
#include <thread>
#include <vector>
@@ -87,9 +88,9 @@ public:
struct ZoneThreadData
{
ZoneEvent* Zone() const { return (ZoneEvent*)( _zone_thread >> 16 ); }
void SetZone( ZoneEvent* zone ) { assert( ( uint64_t( zone ) & 0xFFFF000000000000 ) == 0 ); _zone_thread = ( _zone_thread & 0xFFFF ) | ( uint64_t( zone ) << 16 ); }
void SetZone( ZoneEvent* zone ) { assert( ( uint64_t( zone ) & 0xFFFF000000000000 ) == 0 ); memcpy( ((char*)&_zone_thread)+2, &zone, 6 ); }
uint16_t Thread() const { return uint16_t( _zone_thread & 0xFFFF ); }
void SetThread( uint16_t thread ) { _zone_thread = ( _zone_thread & 0xFFFFFFFFFFFF0000 ) | uint64_t( thread ); }
void SetThread( uint16_t thread ) { memcpy( &_zone_thread, &thread, 2 ); }
uint64_t _zone_thread;
};