From 0fe42320159e977a89f6f0ee882f5e13819c5dcd Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sun, 19 Nov 2017 13:36:03 +0100 Subject: [PATCH] Optimize string wrappers initialization. --- server/TracyEvent.hpp | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/server/TracyEvent.hpp b/server/TracyEvent.hpp index 583e4faf..94deb12c 100644 --- a/server/TracyEvent.hpp +++ b/server/TracyEvent.hpp @@ -15,7 +15,7 @@ struct StringRef { enum Type { Ptr, Idx }; - StringRef() : active( 0 ) {} + StringRef() : __data( 0 ) {} StringRef( Type t, uint64_t data ) : isidx( t == Idx ) , active( 1 ) @@ -36,20 +36,34 @@ struct StringRef uint64_t stridx; }; - uint8_t isidx : 1; - uint8_t active : 1; + union + { + struct + { + uint8_t isidx : 1; + uint8_t active : 1; + }; + uint8_t __data; + }; }; struct StringIdx { - StringIdx() : active( 0 ) {} + StringIdx() : __data( 0 ) {} StringIdx( uint32_t idx ) : idx( idx ) , active( 1 ) {} - uint32_t idx : 31; - uint32_t active : 1; + union + { + struct + { + uint32_t idx : 31; + uint32_t active : 1; + }; + uint32_t __data; + }; }; struct SourceLocation