From 8c45e7db05d76de60d214148a69b5ba927b704a1 Mon Sep 17 00:00:00 2001 From: Neil Date: Fri, 17 Apr 2020 09:46:20 +1000 Subject: Arithmetic between enums is deprecated so use constexpr instead of enum or cast. Added constexpr where reasonable. --- src/RESearch.h | 14 +++++++------- win32/ScintillaWin.cxx | 7 ++++--- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/RESearch.h b/src/RESearch.h index 10ed4380d..49bfc0541 100644 --- a/src/RESearch.h +++ b/src/RESearch.h @@ -29,8 +29,8 @@ public: const char *Compile(const char *pattern, Sci::Position length, bool caseSensitive, bool posix) noexcept; int Execute(const CharacterIndexer &ci, Sci::Position lp, Sci::Position endp); - enum { MAXTAG=10 }; - enum { NOTFOUND=-1 }; + static constexpr int MAXTAG = 10; + static constexpr int NOTFOUND = -1; Sci::Position bopat[MAXTAG]; Sci::Position eopat[MAXTAG]; @@ -38,12 +38,12 @@ public: private: - enum { MAXNFA = 4096 }; - // The following enums are not meant to be changeable. + static constexpr int MAXNFA = 4096; + // The following constants are not meant to be changeable. // They are for readability only. - enum { MAXCHR = 256 }; - enum { CHRBIT = 8 }; - enum { BITBLK = MAXCHR / CHRBIT }; + static constexpr int MAXCHR = 256; + static constexpr int CHRBIT = 8; + static constexpr int BITBLK = MAXCHR / CHRBIT; void ChSet(unsigned char c) noexcept; void ChSetWithCase(unsigned char c, bool caseSensitive) noexcept; diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx index 90af4494b..51563f494 100644 --- a/win32/ScintillaWin.cxx +++ b/win32/ScintillaWin.cxx @@ -1714,7 +1714,7 @@ sptr_t ScintillaWin::IdleMessage(unsigned int iMessage, uptr_t wParam, sptr_t lP #endif const DWORD dwCurrent = GetTickCount(); const DWORD dwStart = wParam ? static_cast(wParam) : dwCurrent; - const DWORD maxWorkTime = 50; + constexpr DWORD maxWorkTime = 50; if (dwCurrent >= dwStart && dwCurrent > maxWorkTime &&dwCurrent - maxWorkTime < dwStart) PostMessage(MainHWND(), SC_WIN_IDLE, dwStart, 0); @@ -1991,10 +1991,11 @@ bool ScintillaWin::FineTickerRunning(TickReason reason) { void ScintillaWin::FineTickerStart(TickReason reason, int millis, int tolerance) { FineTickerCancel(reason); + const UINT_PTR eventID = static_cast(fineTimerStart) + reason; if (SetCoalescableTimerFn && tolerance) { - timers[reason] = SetCoalescableTimerFn(MainHWND(), fineTimerStart + reason, millis, nullptr, tolerance); + timers[reason] = SetCoalescableTimerFn(MainHWND(), eventID, millis, nullptr, tolerance); } else { - timers[reason] = ::SetTimer(MainHWND(), fineTimerStart + reason, millis, nullptr); + timers[reason] = ::SetTimer(MainHWND(), eventID, millis, nullptr); } } -- cgit v1.2.3