From 73694c7a2451377cde671babe7e345b9298200f7 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sat, 24 Jan 2026 01:50:11 +0100 Subject: [PATCH] Cleanup enums. --- extra/identify.cpp | 2 +- import/src/import-chrome.cpp | 2 +- import/src/import-fuchsia.cpp | 2 +- profiler/src/profiler/TracySourceView.hpp | 2 - profiler/src/profiler/TracyStorage.cpp | 12 ++-- profiler/src/profiler/TracyUserData.cpp | 8 +-- profiler/src/profiler/TracyView.cpp | 2 +- profiler/src/profiler/TracyView.hpp | 4 +- profiler/src/profiler/TracyView_Options.cpp | 2 +- profiler/src/profiler/TracyView_Playback.cpp | 2 +- profiler/src/profiler/TracyView_Utility.cpp | 2 +- public/client/TracyCallstack.cpp | 6 +- public/client/TracyProfiler.cpp | 4 +- public/common/TracyProtocol.hpp | 26 +++------ public/common/TracyQueue.hpp | 2 +- public/common/TracySocket.cpp | 2 +- public/common/TracyVersion.hpp | 6 +- public/tracy/TracyOpenCL.hpp | 2 +- public/tracy/TracyOpenGL.hpp | 2 +- public/tracy/TracyVulkan.hpp | 2 +- server/TracyEvent.hpp | 58 +------------------- server/TracyPrint.cpp | 10 ++-- server/TracySortedVector.hpp | 2 +- server/TracyVarArray.hpp | 2 +- server/TracyVector.hpp | 2 +- server/TracyWorker.cpp | 10 ++-- server/TracyWorker.hpp | 2 - 27 files changed, 55 insertions(+), 123 deletions(-) diff --git a/extra/identify.cpp b/extra/identify.cpp index d767b224..f69533b1 100644 --- a/extra/identify.cpp +++ b/extra/identify.cpp @@ -8,7 +8,7 @@ #include "../public/common/TracyVersion.hpp" static const uint8_t FileHeader[8] { 't', 'r', 'a', 'c', 'y', tracy::Version::Major, tracy::Version::Minor, tracy::Version::Patch }; -enum { FileHeaderMagic = 5 }; +constexpr size_t FileHeaderMagic = 5; int main( int argc, char** argv ) { diff --git a/import/src/import-chrome.cpp b/import/src/import-chrome.cpp index 33db741e..30302aa1 100644 --- a/import/src/import-chrome.cpp +++ b/import/src/import-chrome.cpp @@ -89,7 +89,7 @@ int main( int argc, char** argv ) auto zctx = ZSTD_createDStream(); ZSTD_initDStream( zctx ); - enum { tmpSize = 64*1024 }; + constexpr size_t tmpSize = 64*1024; auto tmp = new char[tmpSize]; ZSTD_inBuffer_s zin = { zbuf, (size_t)zsz }; diff --git a/import/src/import-fuchsia.cpp b/import/src/import-fuchsia.cpp index 785979c1..24a2931b 100644 --- a/import/src/import-fuchsia.cpp +++ b/import/src/import-fuchsia.cpp @@ -133,7 +133,7 @@ std::vector read_input(const char *input) { auto zctx = ZSTD_createDStream(); ZSTD_initDStream(zctx); - enum { tmpSize = 64 * 1024 }; + constexpr size_t tmpSize = 64 * 1024; auto tmp = new char[tmpSize]; ZSTD_inBuffer_s zin = {zbuf, (size_t)zsz}; diff --git a/profiler/src/profiler/TracySourceView.hpp b/profiler/src/profiler/TracySourceView.hpp index 82e85815..d33ede79 100644 --- a/profiler/src/profiler/TracySourceView.hpp +++ b/profiler/src/profiler/TracySourceView.hpp @@ -112,8 +112,6 @@ private: uint16_t regData[20]; }; - enum { AsmLineSize = sizeof( AsmLine ) }; - struct JumpData { uint64_t min; diff --git a/profiler/src/profiler/TracyStorage.cpp b/profiler/src/profiler/TracyStorage.cpp index 3f85326d..39816680 100644 --- a/profiler/src/profiler/TracyStorage.cpp +++ b/profiler/src/profiler/TracyStorage.cpp @@ -126,8 +126,8 @@ const char* GetSavePath( const char* file ) { assert( file && *file ); - enum { Pool = 8 }; - enum { MaxPath = 512 }; + constexpr size_t Pool = 8; + constexpr size_t MaxPath = 512; static char bufpool[Pool][MaxPath]; static int bufsel = 0; char* buf = bufpool[bufsel]; @@ -153,8 +153,8 @@ const char* GetSavePath( const char* program, uint64_t time, const char* file, b { assert( program && *program ); - enum { Pool = 8 }; - enum { MaxPath = 512 }; + constexpr size_t Pool = 8; + constexpr size_t MaxPath = 512; static char bufpool[Pool][MaxPath]; static int bufsel = 0; char* buf = bufpool[bufsel]; @@ -246,8 +246,8 @@ const char* GetCachePath( const char* file ) { assert( file && *file ); - enum { Pool = 8 }; - enum { MaxPath = 512 }; + constexpr size_t Pool = 8; + constexpr size_t MaxPath = 512; static char bufpool[Pool][MaxPath]; static int bufsel = 0; char* buf = bufpool[bufsel]; diff --git a/profiler/src/profiler/TracyUserData.cpp b/profiler/src/profiler/TracyUserData.cpp index 60184da9..16e2dabd 100644 --- a/profiler/src/profiler/TracyUserData.cpp +++ b/profiler/src/profiler/TracyUserData.cpp @@ -22,10 +22,10 @@ constexpr auto FileOptions = "options"; constexpr auto FileAnnotations = "annotations"; constexpr auto FileSourceSubstitutions = "srcsub"; -enum : uint32_t { VersionTimeline = 0 }; -enum : uint32_t { VersionOptions = 7 }; -enum : uint32_t { VersionAnnotations = 0 }; -enum : uint32_t { VersionSourceSubstitutions = 0 }; +constexpr uint32_t VersionTimeline = 0; +constexpr uint32_t VersionOptions = 7; +constexpr uint32_t VersionAnnotations = 0; +constexpr uint32_t VersionSourceSubstitutions = 0; UserData::UserData() : m_preserveState( false ) diff --git a/profiler/src/profiler/TracyView.cpp b/profiler/src/profiler/TracyView.cpp index 015e3831..9a186eab 100644 --- a/profiler/src/profiler/TracyView.cpp +++ b/profiler/src/profiler/TracyView.cpp @@ -686,7 +686,7 @@ static const char* MainWindowButtons[] = { ICON_FA_SQUARE " Stopped" }; -enum { MainWindowButtonsCount = sizeof( MainWindowButtons ) / sizeof( *MainWindowButtons ) }; +constexpr size_t MainWindowButtonsCount = sizeof( MainWindowButtons ) / sizeof( *MainWindowButtons ); bool View::DrawImpl() { diff --git a/profiler/src/profiler/TracyView.hpp b/profiler/src/profiler/TracyView.hpp index d0876e71..f497199e 100644 --- a/profiler/src/profiler/TracyView.hpp +++ b/profiler/src/profiler/TracyView.hpp @@ -192,7 +192,7 @@ private: OpenFind }; - enum { InvalidId = 0xFFFFFFFF }; + static constexpr uint32_t InvalidId = 0xFFFFFFFF; struct MemPathData { @@ -681,7 +681,7 @@ private: int m_gpuIdx = 0; struct FindZone { - enum : uint64_t { Unselected = std::numeric_limits::max() - 1 }; + static constexpr uint64_t Unselected = std::numeric_limits::max() - 1; enum class GroupBy : int { Thread, UserText, ZoneName, Callstack, Parent, NoGrouping }; enum class SortBy : int { Order, Count, Time, Mtpc }; diff --git a/profiler/src/profiler/TracyView_Options.cpp b/profiler/src/profiler/TracyView_Options.cpp index 45ca4fac..dd8256f1 100644 --- a/profiler/src/profiler/TracyView_Options.cpp +++ b/profiler/src/profiler/TracyView_Options.cpp @@ -183,7 +183,7 @@ void View::DrawOptions() } } - enum { NumSlopes = 10000 }; + constexpr size_t NumSlopes = 10000; std::random_device rd; std::default_random_engine gen( rd() ); std::uniform_int_distribution dist( 0, lastidx - 1 ); diff --git a/profiler/src/profiler/TracyView_Playback.cpp b/profiler/src/profiler/TracyView_Playback.cpp index bf4f7569..9016f81f 100644 --- a/profiler/src/profiler/TracyView_Playback.cpp +++ b/profiler/src/profiler/TracyView_Playback.cpp @@ -31,7 +31,7 @@ static const char* PlaybackWindowButtons[] = { ICON_FA_PAUSE " Pause", }; -enum { PlaybackWindowButtonsCount = sizeof( PlaybackWindowButtons ) / sizeof( *PlaybackWindowButtons ) }; +constexpr size_t PlaybackWindowButtonsCount = sizeof( PlaybackWindowButtons ) / sizeof( *PlaybackWindowButtons ); void View::DrawPlayback() { diff --git a/profiler/src/profiler/TracyView_Utility.cpp b/profiler/src/profiler/TracyView_Utility.cpp index bc864f3f..b30b5cdf 100644 --- a/profiler/src/profiler/TracyView_Utility.cpp +++ b/profiler/src/profiler/TracyView_Utility.cpp @@ -832,7 +832,7 @@ const char* View::GetFrameSetName( const FrameData& fd ) const const char* View::GetFrameSetName( const FrameData& fd, const Worker& worker ) { - enum { Pool = 4 }; + constexpr size_t Pool = 4; static char bufpool[Pool][64]; static int bufsel = 0; diff --git a/public/client/TracyCallstack.cpp b/public/client/TracyCallstack.cpp index 3cc41386..ac224227 100644 --- a/public/client/TracyCallstack.cpp +++ b/public/client/TracyCallstack.cpp @@ -347,8 +347,8 @@ bool ShouldResolveSymbolsOffline() #if TRACY_HAS_CALLSTACK == 1 -enum { MaxCbTrace = 64 }; -enum { MaxNameSize = 8*1024 }; +constexpr size_t MaxCbTrace = 64; +constexpr size_t MaxNameSize = 8*1024; int cb_num; CallstackEntry cb_data[MaxCbTrace]; @@ -829,7 +829,7 @@ CallstackEntryData DecodeCallstackPtr( uint64_t ptr ) #elif defined(TRACY_USE_LIBBACKTRACE) -enum { MaxCbTrace = 64 }; +constexpr size_t MaxCbTrace = 64; struct backtrace_state* cb_bts = nullptr; diff --git a/public/client/TracyProfiler.cpp b/public/client/TracyProfiler.cpp index 2771f7a6..81c4aa65 100644 --- a/public/client/TracyProfiler.cpp +++ b/public/client/TracyProfiler.cpp @@ -634,7 +634,7 @@ static const char* GetHostInfo() FILE* fcpuinfo = fopen( "/proc/cpuinfo", "rb" ); if( fcpuinfo ) { - enum { BufSize = 4*1024 }; + constexpr size_t BufSize = 4*1024; char buf[BufSize]; const auto sz = fread( buf, 1, BufSize, fcpuinfo ); fclose( fcpuinfo ); @@ -1198,7 +1198,7 @@ void Profiler::EndSamplingProfiling() #endif } -enum { QueuePrealloc = 256 * 1024 }; +constexpr size_t QueuePrealloc = 256 * 1024; TRACY_API int64_t GetFrequencyQpc() { diff --git a/public/common/TracyProtocol.hpp b/public/common/TracyProtocol.hpp index a354b057..74a037ba 100644 --- a/public/common/TracyProtocol.hpp +++ b/public/common/TracyProtocol.hpp @@ -2,6 +2,7 @@ #define __TRACYPROTOCOL_HPP__ #include +#include #include namespace tracy @@ -9,17 +10,17 @@ namespace tracy constexpr unsigned Lz4CompressBound( unsigned isize ) { return isize + ( isize / 255 ) + 16; } -enum : uint32_t { ProtocolVersion = 77 }; -enum : uint16_t { BroadcastVersion = 3 }; +constexpr uint32_t ProtocolVersion = 77; +constexpr uint16_t BroadcastVersion = 3; using lz4sz_t = uint32_t; -enum { TargetFrameSize = 256 * 1024 }; -enum { LZ4Size = Lz4CompressBound( TargetFrameSize ) }; +constexpr unsigned TargetFrameSize = 256 * 1024; +constexpr unsigned LZ4Size = Lz4CompressBound( TargetFrameSize ); static_assert( LZ4Size <= (std::numeric_limits::max)(), "LZ4Size greater than lz4sz_t" ); static_assert( TargetFrameSize * 2 >= 64 * 1024, "Not enough space for LZ4 stream buffer" ); -enum { HandshakeShibbolethSize = 8 }; +constexpr size_t HandshakeShibbolethSize = 8; static const char HandshakeShibboleth[HandshakeShibbolethSize] = { 'T', 'r', 'a', 'c', 'y', 'P', 'r', 'f' }; enum HandshakeStatus : uint8_t @@ -31,8 +32,8 @@ enum HandshakeStatus : uint8_t HandshakeDropped }; -enum { WelcomeMessageProgramNameSize = 64 }; -enum { WelcomeMessageHostInfoSize = 1024 }; +constexpr size_t WelcomeMessageHostInfoSize = 1024; +constexpr size_t WelcomeMessageProgramNameSize = 64; #pragma pack( push, 1 ) @@ -65,7 +66,7 @@ struct ServerQueryPacket uint32_t extra; }; -enum { ServerQueryPacketSize = sizeof( ServerQueryPacket ) }; +constexpr size_t ServerQueryPacketSize = sizeof( ServerQueryPacket ); enum CpuArchitecture : uint8_t @@ -108,8 +109,6 @@ struct WelcomeMessage char hostInfo[WelcomeMessageHostInfoSize]; }; -enum { WelcomeMessageSize = sizeof( WelcomeMessage ) }; - struct OnDemandPayloadMessage { @@ -117,8 +116,6 @@ struct OnDemandPayloadMessage uint64_t currentTime; }; -enum { OnDemandPayloadMessageSize = sizeof( OnDemandPayloadMessage ) }; - struct BroadcastMessage { @@ -156,11 +153,6 @@ struct BroadcastMessage_v0 char programName[WelcomeMessageProgramNameSize]; }; -enum { BroadcastMessageSize = sizeof( BroadcastMessage ) }; -enum { BroadcastMessageSize_v2 = sizeof( BroadcastMessage_v2 ) }; -enum { BroadcastMessageSize_v1 = sizeof( BroadcastMessage_v1 ) }; -enum { BroadcastMessageSize_v0 = sizeof( BroadcastMessage_v0 ) }; - #pragma pack( pop ) } diff --git a/public/common/TracyQueue.hpp b/public/common/TracyQueue.hpp index 7d64982c..e5f684c6 100644 --- a/public/common/TracyQueue.hpp +++ b/public/common/TracyQueue.hpp @@ -874,7 +874,7 @@ struct QueueItem #pragma pack( pop ) -enum { QueueItemSize = sizeof( QueueItem ) }; +constexpr size_t QueueItemSize = sizeof( QueueItem ); static constexpr size_t QueueDataSize[] = { sizeof( QueueHeader ), // zone text diff --git a/public/common/TracySocket.cpp b/public/common/TracySocket.cpp index bdba3619..767593f6 100644 --- a/public/common/TracySocket.cpp +++ b/public/common/TracySocket.cpp @@ -70,7 +70,7 @@ void InitWinSock() #endif -enum { BufSize = 128 * 1024 }; +constexpr size_t BufSize = 128 * 1024; Socket::Socket() : m_buf( (char*)tracy_malloc( BufSize ) ) diff --git a/public/common/TracyVersion.hpp b/public/common/TracyVersion.hpp index ee7ee13a..51308bc3 100644 --- a/public/common/TracyVersion.hpp +++ b/public/common/TracyVersion.hpp @@ -5,9 +5,9 @@ namespace tracy { namespace Version { -enum { Major = 0 }; -enum { Minor = 13 }; -enum { Patch = 2 }; +constexpr int Major = 0; +constexpr int Minor = 13; +constexpr int Patch = 2; } } diff --git a/public/tracy/TracyOpenCL.hpp b/public/tracy/TracyOpenCL.hpp index ede5c461..9864a5c0 100644 --- a/public/tracy/TracyOpenCL.hpp +++ b/public/tracy/TracyOpenCL.hpp @@ -76,7 +76,7 @@ namespace tracy { class OpenCLCtx { public: - enum { QueryCount = 64 * 1024 }; + static constexpr size_t QueryCount = 64 * 1024; OpenCLCtx(cl_context context, cl_device_id device) : m_contextId(GetGpuCtxCounter().fetch_add(1, std::memory_order_relaxed)) diff --git a/public/tracy/TracyOpenGL.hpp b/public/tracy/TracyOpenGL.hpp index 30abd4fd..a1e59329 100644 --- a/public/tracy/TracyOpenGL.hpp +++ b/public/tracy/TracyOpenGL.hpp @@ -87,7 +87,7 @@ class GpuCtx { friend class GpuCtxScope; - enum { QueryCount = 64 * 1024 }; + static constexpr size_t QueryCount = 64 * 1024; public: GpuCtx() diff --git a/public/tracy/TracyVulkan.hpp b/public/tracy/TracyVulkan.hpp index 429f299d..ce5acc99 100644 --- a/public/tracy/TracyVulkan.hpp +++ b/public/tracy/TracyVulkan.hpp @@ -91,7 +91,7 @@ class VkCtx { friend class VkCtxScope; - enum { QueryCount = 64 * 1024 }; + static constexpr size_t QueryCount = 64 * 1024; public: #if defined TRACY_VK_USE_SYMBOL_TABLE diff --git a/server/TracyEvent.hpp b/server/TracyEvent.hpp index 21df6784..075479a5 100644 --- a/server/TracyEvent.hpp +++ b/server/TracyEvent.hpp @@ -196,8 +196,6 @@ struct SourceLocation : public SourceLocationBase mutable uint32_t namehash; }; -enum { SourceLocationSize = sizeof( SourceLocation ) }; - struct ZoneEvent { @@ -222,7 +220,6 @@ struct ZoneEvent uint32_t extra; }; -enum { ZoneEventSize = sizeof( ZoneEvent ) }; static_assert( std::is_standard_layout::value, "ZoneEvent is not standard layout" ); @@ -234,8 +231,6 @@ struct ZoneExtra Int24 color; }; -enum { ZoneExtraSize = sizeof( ZoneExtra ) }; - // This union exploits the fact that the current implementations of x64 and arm64 do not provide // full 64 bit address space. The high bits must be bit-extended, so 0x80... is an invalid pointer. @@ -251,8 +246,6 @@ union CallstackFrameId uint64_t data; }; -enum { CallstackFrameIdSize = sizeof( CallstackFrameId ) }; - static tracy_force_inline bool operator==( const CallstackFrameId& lhs, const CallstackFrameId& rhs ) { return lhs.data == rhs.data; } @@ -262,8 +255,6 @@ struct SampleData Int24 callstack; }; -enum { SampleDataSize = sizeof( SampleData ) }; - struct SampleDataSort { bool operator()( const SampleData& lhs, const SampleData& rhs ) const { return lhs.time.Val() < rhs.time.Val(); }; }; @@ -274,8 +265,6 @@ struct SampleDataRange CallstackFrameId ip; }; -enum { SampleDataRangeSize = sizeof( SampleDataRange ) }; - struct HwSampleData { @@ -308,8 +297,6 @@ struct HwSampleData } }; -enum { HwSampleDataSize = sizeof( HwSampleData ) }; - struct LockEvent { @@ -347,11 +334,7 @@ struct LockEventPtr uint64_t waitList; }; -enum { LockEventSize = sizeof( LockEvent ) }; -enum { LockEventSharedSize = sizeof( LockEventShared ) }; -enum { LockEventPtrSize = sizeof( LockEventPtr ) }; - -enum { MaxLockThreads = sizeof( LockEventPtr::waitList ) * 8 }; +constexpr size_t MaxLockThreads = sizeof( LockEventPtr::waitList ) * 8; static_assert( std::numeric_limits::max() >= MaxLockThreads, "Not enough space for lock count." ); @@ -415,7 +398,6 @@ struct GpuEvent uint16_t query_id; }; -enum { GpuEventSize = sizeof( GpuEvent ) }; static_assert( std::is_standard_layout::value, "GpuEvent is not standard layout" ); @@ -446,7 +428,6 @@ struct MemEvent uint64_t _time_thread_free; }; -enum { MemEventSize = sizeof( MemEvent ) }; static_assert( std::is_standard_layout::value, "MemEvent is not standard layout" ); @@ -471,10 +452,6 @@ struct SymbolData : public CallstackFrameBasic Int24 size; }; -enum { CallstackFrameBasicSize = sizeof( CallstackFrameBasic ) }; -enum { CallstackFrameSize = sizeof( CallstackFrame ) }; -enum { SymbolDataSize = sizeof( SymbolData ) }; - struct SymbolLocation { @@ -482,8 +459,6 @@ struct SymbolLocation uint32_t len; }; -enum { SymbolLocationSize = sizeof( SymbolLocation ) }; - struct CallstackFrameData { @@ -492,8 +467,6 @@ struct CallstackFrameData StringIdx imageName; }; -enum { CallstackFrameDataSize = sizeof( CallstackFrameData ) }; - struct MemCallstackFrameTree { @@ -506,8 +479,6 @@ struct MemCallstackFrameTree unordered_flat_set callstacks; }; -enum { MemCallstackFrameTreeSize = sizeof( MemCallstackFrameTree ) }; - struct CallstackFrameTree { @@ -518,8 +489,6 @@ struct CallstackFrameTree unordered_flat_map children; }; -enum { CallstackFrameTreeSize = sizeof( CallstackFrameTree ) }; - struct CrashEvent { @@ -529,7 +498,6 @@ struct CrashEvent uint32_t callstack = 0; }; -enum { CrashEventSize = sizeof( CrashEvent ) }; /** * Represents a context switch. @@ -620,8 +588,6 @@ struct ContextSwitchData uint16_t _thread; // currently unused ? Could store next thread or prios here. }; -enum { ContextSwitchDataSize = sizeof( ContextSwitchData ) }; - struct ContextSwitchCpu { @@ -639,8 +605,6 @@ struct ContextSwitchCpu Int48 _end; }; -enum { ContextSwitchCpuSize = sizeof( ContextSwitchCpu ) }; - struct ContextSwitchUsage { @@ -657,8 +621,6 @@ struct ContextSwitchUsage uint64_t _time_other_own; }; -enum { ContextSwitchUsageSize = sizeof( ContextSwitchUsage ) }; - struct MessageData { @@ -671,8 +633,6 @@ struct MessageData MessageSeverity severity; }; -enum { MessageDataSize = sizeof( MessageData ) }; - struct PlotItem { @@ -680,8 +640,6 @@ struct PlotItem double val; }; -enum { PlotItemSize = sizeof( PlotItem ) }; - struct FrameEvent { @@ -690,8 +648,6 @@ struct FrameEvent int32_t frameImage; }; -enum { FrameEventSize = sizeof( FrameEvent ) }; - struct FrameImage { @@ -702,8 +658,6 @@ struct FrameImage uint8_t flip; }; -enum { FrameImageSize = sizeof( FrameImage ) }; - struct GhostZone { @@ -712,8 +666,6 @@ struct GhostZone int32_t child; }; -enum { GhostZoneSize = sizeof( GhostZone ) }; - struct ChildSample { @@ -721,8 +673,6 @@ struct ChildSample uint64_t addr; }; -enum { ChildSampleSize = sizeof( ChildSample ) }; - #pragma pack( pop ) @@ -782,8 +732,6 @@ struct GpuCtxData short_ptr query[64*1024]; }; -enum { GpuCtxDataSize = sizeof( GpuCtxData ) }; - enum class PlotType : uint8_t { @@ -890,8 +838,6 @@ struct CpuThreadData uint32_t migrations = 0; }; -enum { CpuThreadDataSize = sizeof( CpuThreadData ) }; - struct Parameter { @@ -909,8 +855,6 @@ struct SymbolStats unordered_flat_map baseParents; }; -enum { SymbolStatsSize = sizeof( SymbolStats ) }; - struct FlameGraphItem { diff --git a/server/TracyPrint.cpp b/server/TracyPrint.cpp index 9111ddb0..538a09af 100644 --- a/server/TracyPrint.cpp +++ b/server/TracyPrint.cpp @@ -173,7 +173,7 @@ uint64_t _int64_abs( int64_t x ) const char* TimeToString( int64_t _ns ) { - enum { Pool = 8 }; + constexpr size_t Pool = 8; static char bufpool[Pool][64]; static int bufsel = 0; char* buf = bufpool[bufsel]; @@ -249,7 +249,7 @@ const char* TimeToString( int64_t _ns ) const char* TimeToStringExact( int64_t _ns ) { - enum { Pool = 8 }; + constexpr size_t Pool = 8; static char bufpool[Pool][64]; static int bufsel = 0; char* buf = bufpool[bufsel]; @@ -358,7 +358,7 @@ const char* TimeToStringExact( int64_t _ns ) const char* MemSizeToString( int64_t val ) { - enum { Pool = 8 }; + constexpr size_t Pool = 8; static char bufpool[Pool][64]; static int bufsel = 0; char* buf = bufpool[bufsel]; @@ -436,7 +436,7 @@ const char* LocationToString( const char* fn, uint32_t line ) { if( line == 0 ) return fn; - enum { Pool = 8 }; + constexpr size_t Pool = 8; static char bufpool[Pool][4096]; static int bufsel = 0; char* buf = bufpool[bufsel]; @@ -451,7 +451,7 @@ namespace detail char* RealToStringGetBuffer() { - enum { Pool = 8 }; + constexpr size_t Pool = 8; static char bufpool[Pool][64]; static int bufsel = 0; char* buf = bufpool[bufsel]; diff --git a/server/TracySortedVector.hpp b/server/TracySortedVector.hpp index 1a6a6da5..13e09df4 100644 --- a/server/TracySortedVector.hpp +++ b/server/TracySortedVector.hpp @@ -120,7 +120,7 @@ private: #pragma pack( pop ) -enum { SortedVectorSize = sizeof( SortedVector ) }; +constexpr size_t SortedVectorSize = sizeof( SortedVector ); } diff --git a/server/TracyVarArray.hpp b/server/TracyVarArray.hpp index 83515794..3862ae73 100644 --- a/server/TracyVarArray.hpp +++ b/server/TracyVarArray.hpp @@ -58,7 +58,7 @@ private: }; #pragma pack( pop ) -enum { VarArraySize = sizeof( VarArray ) }; +constexpr size_t VarArraySize = sizeof( VarArray ); template diff --git a/server/TracyVector.hpp b/server/TracyVector.hpp index c44a4417..bb8ead48 100644 --- a/server/TracyVector.hpp +++ b/server/TracyVector.hpp @@ -350,7 +350,7 @@ template struct VectorAdapterPointer { const T& operator()( const sh #pragma pack( pop ) -enum { VectorSize = sizeof( Vector ) }; +constexpr size_t VectorSize = sizeof( Vector ); } diff --git a/server/TracyWorker.cpp b/server/TracyWorker.cpp index d69fe806..671569ed 100644 --- a/server/TracyWorker.cpp +++ b/server/TracyWorker.cpp @@ -54,7 +54,7 @@ static bool SourceFileValid( const char* fn, uint64_t olderThan ) static const uint8_t FileHeader[8] { 't', 'r', 'a', 'c', 'y', Version::Major, Version::Minor, Version::Patch }; -enum { FileHeaderMagic = 5 }; +constexpr size_t FileHeaderMagic = 5; static const int CurrentVersion = FileVersion( Version::Major, Version::Minor, Version::Patch ); static const int MinSupportedVersion = FileVersion( 0, 9, 0 ); @@ -2840,7 +2840,7 @@ void Worker::Exec() } } - m_serverQuerySpaceBase = m_serverQuerySpaceLeft = std::min( ( m_sock.GetSendBufSize() / ServerQueryPacketSize ), 8*1024 ) - 4; // leave space for terminate request + m_serverQuerySpaceBase = m_serverQuerySpaceLeft = std::min( ( m_sock.GetSendBufSize() / ServerQueryPacketSize ), size_t( 8*1024 ) ) - 4; // leave space for terminate request m_hasData.store( true, std::memory_order_release ); LZ4_setStreamDecode( (LZ4_streamDecode_t*)m_stream, nullptr, 0 ); @@ -2932,7 +2932,7 @@ void Worker::Exec() auto t1 = std::chrono::high_resolution_clock::now(); auto td = std::chrono::duration_cast( t1 - t0 ).count(); - enum { MbpsUpdateTime = 200 }; + constexpr int MbpsUpdateTime = 200; if( td > MbpsUpdateTime ) { UpdateMbps( td ); @@ -8346,8 +8346,8 @@ void Worker::Write( FileWrite& f, bool fiDict ) sz = m_data.frameImage.size(); if( fiDict ) { - enum : uint32_t { DictSize = 4*1024*1024 }; - enum : uint32_t { SamplesLimit = 1U << 31 }; + constexpr uint32_t DictSize = 4*1024*1024; + constexpr uint32_t SamplesLimit = 1U << 31; uint32_t sNum = 0; uint32_t sSize = 0; for( auto& fi : m_data.frameImage ) diff --git a/server/TracyWorker.hpp b/server/TracyWorker.hpp index 44044e09..11577aaa 100644 --- a/server/TracyWorker.hpp +++ b/server/TracyWorker.hpp @@ -132,7 +132,6 @@ public: uint64_t _zone_thread; }; - enum { ZoneThreadDataSize = sizeof( ZoneThreadData ) }; struct GpuZoneThreadData { @@ -143,7 +142,6 @@ public: uint64_t _zone_thread; }; - enum { GpuZoneThreadDataSize = sizeof( GpuZoneThreadData ) }; struct CpuThreadTopology {