diff options
-rw-r--r-- | src/Document.cxx | 6 | ||||
-rw-r--r-- | src/Document.h | 2 | ||||
-rw-r--r-- | src/Editor.cxx | 26 |
3 files changed, 21 insertions, 13 deletions
diff --git a/src/Document.cxx b/src/Document.cxx index 0f71ba843..f9cd654c7 100644 --- a/src/Document.cxx +++ b/src/Document.cxx @@ -1089,7 +1089,7 @@ int Document::DBCSDrawBytes(std::string_view text) const noexcept { } } -static inline bool IsSpaceOrTab(int ch) noexcept { +static constexpr bool IsSpaceOrTab(int ch) noexcept { return ch == ' ' || ch == '\t'; } @@ -1435,7 +1435,7 @@ void Document::DelCharBack(Sci::Position pos) { } } -static Sci::Position NextTab(Sci::Position pos, Sci::Position tabSize) noexcept { +static constexpr Sci::Position NextTab(Sci::Position pos, Sci::Position tabSize) noexcept { return ((pos / tabSize) + 1) * tabSize; } @@ -2551,7 +2551,7 @@ Sci::Position Document::WordPartRight(Sci::Position pos) const { return pos; } -static bool IsLineEndChar(char c) noexcept { +static constexpr bool IsLineEndChar(char c) noexcept { return (c == '\n' || c == '\r'); } diff --git a/src/Document.h b/src/Document.h index 3eeeef029..de986ce2a 100644 --- a/src/Document.h +++ b/src/Document.h @@ -164,7 +164,7 @@ public: bool isEnabled; }; -inline int LevelNumber(int level) noexcept { +constexpr int LevelNumber(int level) noexcept { return level & SC_FOLDLEVELNUMBERMASK; } diff --git a/src/Editor.cxx b/src/Editor.cxx index b68643c8f..9821b1195 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -58,11 +58,13 @@ using namespace Scintilla; +namespace { + /* return whether this modification represents an operation that may reasonably be deferred (not done now OR [possibly] at all) */ -static bool CanDeferToLastStep(const DocModification &mh) noexcept { +constexpr bool CanDeferToLastStep(const DocModification &mh) noexcept { if (mh.modificationType & (SC_MOD_BEFOREINSERT | SC_MOD_BEFOREDELETE)) return true; // CAN skip if (!(mh.modificationType & (SC_PERFORMED_UNDO | SC_PERFORMED_REDO))) @@ -72,7 +74,7 @@ static bool CanDeferToLastStep(const DocModification &mh) noexcept { return false; // PRESUMABLY must do } -static bool CanEliminate(const DocModification &mh) noexcept { +constexpr bool CanEliminate(const DocModification &mh) noexcept { return (mh.modificationType & (SC_MOD_BEFOREINSERT | SC_MOD_BEFOREDELETE)) != 0; } @@ -81,7 +83,7 @@ static bool CanEliminate(const DocModification &mh) noexcept { return whether this modification represents the FINAL step in a [possibly lengthy] multi-step Undo/Redo sequence */ -static bool IsLastStep(const DocModification &mh) noexcept { +constexpr bool IsLastStep(const DocModification &mh) noexcept { return (mh.modificationType & (SC_PERFORMED_UNDO | SC_PERFORMED_REDO)) != 0 && (mh.modificationType & SC_MULTISTEPUNDOREDO) != 0 @@ -89,13 +91,15 @@ static bool IsLastStep(const DocModification &mh) noexcept { && (mh.modificationType & SC_MULTILINEUNDOREDO) != 0; } +} + Timer::Timer() noexcept : ticking(false), ticksToWait(0), tickerID{} {} Idler::Idler() noexcept : state(false), idlerID(0) {} -static inline bool IsAllSpacesOrTabs(const char *s, unsigned int len) noexcept { +static constexpr bool IsAllSpacesOrTabs(const char *s, unsigned int len) noexcept { for (unsigned int i = 0; i < len; i++) { // This is safe because IsSpaceOrTab() will return false for null terminators if (!IsSpaceOrTab(s[i])) @@ -2523,8 +2527,10 @@ void Editor::CheckModificationForWrap(DocModification mh) { } } +namespace { + // Move a position so it is still after the same character as before the insertion. -static inline Sci::Position MovePositionForInsertion(Sci::Position position, Sci::Position startInsertion, Sci::Position length) noexcept { +constexpr Sci::Position MovePositionForInsertion(Sci::Position position, Sci::Position startInsertion, Sci::Position length) noexcept { if (position > startInsertion) { return position + length; } @@ -2533,7 +2539,7 @@ static inline Sci::Position MovePositionForInsertion(Sci::Position position, Sci // Move a position so it is still after the same character as before the deletion if that // character is still present else after the previous surviving character. -static inline Sci::Position MovePositionForDeletion(Sci::Position position, Sci::Position startDeletion, Sci::Position length) noexcept { +constexpr Sci::Position MovePositionForDeletion(Sci::Position position, Sci::Position startDeletion, Sci::Position length) noexcept { if (position > startDeletion) { const Sci::Position endDeletion = startDeletion + length; if (position > endDeletion) { @@ -2546,6 +2552,8 @@ static inline Sci::Position MovePositionForDeletion(Sci::Position position, Sci: } } +} + void Editor::NotifyModified(Document *, DocModification mh, void *) { ContainerNeedsUpdate(SC_UPDATE_CONTENT); if (paintState == painting) { @@ -3234,7 +3242,7 @@ constexpr short LowShortFromWParam(uptr_t x) { return static_cast<short>(x & 0xffff); } -unsigned int WithExtends(unsigned int iMessage) noexcept { +constexpr unsigned int WithExtends(unsigned int iMessage) noexcept { switch (iMessage) { case SCI_CHARLEFT: return SCI_CHARLEFTEXTEND; case SCI_CHARRIGHT: return SCI_CHARRIGHTEXTEND; @@ -3261,7 +3269,7 @@ unsigned int WithExtends(unsigned int iMessage) noexcept { } } -int NaturalDirection(unsigned int iMessage) noexcept { +constexpr int NaturalDirection(unsigned int iMessage) noexcept { switch (iMessage) { case SCI_CHARLEFT: case SCI_CHARLEFTEXTEND: @@ -3292,7 +3300,7 @@ int NaturalDirection(unsigned int iMessage) noexcept { } } -bool IsRectExtend(unsigned int iMessage, bool isRectMoveExtends) noexcept { +constexpr bool IsRectExtend(unsigned int iMessage, bool isRectMoveExtends) noexcept { switch (iMessage) { case SCI_CHARLEFTRECTEXTEND: case SCI_CHARRIGHTRECTEXTEND: |