From f57c71bd23e833e34e09368248e529bb07296816 Mon Sep 17 00:00:00 2001 From: sukibaby <163092272+sukibaby@users.noreply.github.com> Date: Mon, 16 Dec 2024 06:34:45 -0800 Subject: [PATCH] Ensure a consistent definition of TimingSegment::EPSILON Since the EPSILON variable in the header file was declared but not assigned any value, it could lead to undefined behavior or calculation errors when the variable is used without initialization. This ensures a consistent value is always used and is also defined at compile time for further safety. --- src/TimingSegments.cpp | 3 --- src/TimingSegments.h | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/TimingSegments.cpp b/src/TimingSegments.cpp index 31f5acd684..2faf26237d 100644 --- a/src/TimingSegments.cpp +++ b/src/TimingSegments.cpp @@ -4,9 +4,6 @@ #include - -const double TimingSegment::EPSILON = 1e-6; - static const char *TimingSegmentTypeNames[] = { "BPM", "Stop", diff --git a/src/TimingSegments.h b/src/TimingSegments.h index dd1ed5df97..8769d82ed8 100644 --- a/src/TimingSegments.h +++ b/src/TimingSegments.h @@ -64,7 +64,7 @@ struct TimingSegment m_iStartRow( other.GetRow() ) { } // for our purposes, two floats within this level of error are equal - static const double EPSILON; + static constexpr double EPSILON = 1e-6; virtual ~TimingSegment() { }