diff options
author | Neil <nyamatongwe@gmail.com> | 2018-06-10 13:33:03 +1000 |
---|---|---|
committer | Neil <nyamatongwe@gmail.com> | 2018-06-10 13:33:03 +1000 |
commit | 2d87b5e5e8058c3ca4f574deb08305e3ae5812ff (patch) | |
tree | 52901b7addc1c3ee2195e9d6133fe3572b74502e | |
parent | dc54c96dc1a32afeae5705360b7f6cc8b51c887e (diff) | |
download | scintilla-mirror-2d87b5e5e8058c3ca4f574deb08305e3ae5812ff.tar.gz |
Using noexcept for simple functions.
-rw-r--r-- | src/CellBuffer.h | 2 | ||||
-rw-r--r-- | src/Document.cxx | 12 | ||||
-rw-r--r-- | src/Document.h | 58 |
3 files changed, 36 insertions, 36 deletions
diff --git a/src/CellBuffer.h b/src/CellBuffer.h index 838968ec7..f360b2a23 100644 --- a/src/CellBuffer.h +++ b/src/CellBuffer.h @@ -86,7 +86,7 @@ public: // Tentative actions are used for input composition so that it can be undone cleanly void TentativeStart(); void TentativeCommit(); - bool TentativeActive() const { return tentativePoint >= 0; } + bool TentativeActive() const noexcept { return tentativePoint >= 0; } int TentativeSteps(); /// To perform an undo, StartUndo is called to retrieve the number of steps, then UndoStep is diff --git a/src/Document.cxx b/src/Document.cxx index 31e40f7db..f3d8557ac 100644 --- a/src/Document.cxx +++ b/src/Document.cxx @@ -1071,7 +1071,7 @@ static inline bool IsSpaceOrTab(int ch) noexcept { // 2) Break before punctuation // 3) Break after whole character -int Document::SafeSegment(const char *text, int length, int lengthSegment) const { +int Document::SafeSegment(const char *text, int length, int lengthSegment) const noexcept { if (length <= lengthSegment) return length; int lastSpaceBreak = -1; @@ -1105,7 +1105,7 @@ int Document::SafeSegment(const char *text, int length, int lengthSegment) const return lastEncodingAllowedBreak; } -EncodingFamily Document::CodePageFamily() const { +EncodingFamily Document::CodePageFamily() const noexcept { if (SC_CP_UTF8 == dbcsCodePage) return efUnicode; else if (dbcsCodePage) @@ -1114,7 +1114,7 @@ EncodingFamily Document::CodePageFamily() const { return efEightBit; } -void Document::ModifiedAt(Sci::Position pos) { +void Document::ModifiedAt(Sci::Position pos) noexcept { if (endStyled > pos) endStyled = pos; } @@ -1906,7 +1906,7 @@ bool Document::MatchesWordOptions(bool word, bool wordStart, Sci::Position pos, (wordStart && IsWordStartAt(pos)); } -bool Document::HasCaseFolder() const { +bool Document::HasCaseFolder() const noexcept { return pcf != nullptr; } @@ -2105,7 +2105,7 @@ const char *Document::SubstituteByPosition(const char *text, Sci::Position *leng return 0; } -Sci::Line Document::LinesTotal() const { +Sci::Line Document::LinesTotal() const noexcept { return cb.Lines(); } @@ -2329,7 +2329,7 @@ void Document::AnnotationClearAll() { Annotations()->ClearAll(); } -void Document::IncrementStyleClock() { +void Document::IncrementStyleClock() noexcept { styleClock = (styleClock + 1) % 0x100000; } diff --git a/src/Document.h b/src/Document.h index db6d79066..e1613cb20 100644 --- a/src/Document.h +++ b/src/Document.h @@ -31,31 +31,31 @@ public: Sci::Position start; Sci::Position end; - explicit Range(Sci::Position pos=0) : + explicit Range(Sci::Position pos=0) noexcept : start(pos), end(pos) { } - Range(Sci::Position start_, Sci::Position end_) : + Range(Sci::Position start_, Sci::Position end_) noexcept : start(start_), end(end_) { } - bool operator==(const Range &other) const { + bool operator==(const Range &other) const noexcept { return (start == other.start) && (end == other.end); } - bool Valid() const { + bool Valid() const noexcept { return (start != Sci::invalidPosition) && (end != Sci::invalidPosition); } - Sci::Position First() const { + Sci::Position First() const noexcept { return (start <= end) ? start : end; } - Sci::Position Last() const { + Sci::Position Last() const noexcept { return (start > end) ? start : end; } // Is the position within the range? - bool Contains(Sci::Position pos) const { + bool Contains(Sci::Position pos) const noexcept { if (start < end) { return (pos >= start && pos <= end); } else { @@ -64,7 +64,7 @@ public: } // Is the character after pos within the range? - bool ContainsCharacter(Sci::Position pos) const { + bool ContainsCharacter(Sci::Position pos) const noexcept { if (start < end) { return (pos >= start && pos < end); } else { @@ -72,11 +72,11 @@ public: } } - bool Contains(Range other) const { + bool Contains(Range other) const noexcept { return Contains(other.start) && Contains(other.end); } - bool Overlaps(Range other) const { + bool Overlaps(Range other) const noexcept { return Contains(other.start) || Contains(other.end) || @@ -108,18 +108,18 @@ struct StyledText { bool multipleStyles; size_t style; const unsigned char *styles; - StyledText(size_t length_, const char *text_, bool multipleStyles_, int style_, const unsigned char *styles_) : + StyledText(size_t length_, const char *text_, bool multipleStyles_, int style_, const unsigned char *styles_) noexcept : length(length_), text(text_), multipleStyles(multipleStyles_), style(style_), styles(styles_) { } // Return number of bytes from start to before '\n' or end of text. // Return 1 when start is outside text - size_t LineLength(size_t start) const { + size_t LineLength(size_t start) const noexcept { size_t cur = start; while ((cur < length) && (text[cur] != '\n')) cur++; return cur-start; } - size_t StyleAt(size_t i) const { + size_t StyleAt(size_t i) const noexcept { return multipleStyles ? styles[i] : style; } }; @@ -164,7 +164,7 @@ public: bool isEnabled; }; -inline int LevelNumber(int level) { +inline int LevelNumber(int level) noexcept { return level & SC_FOLDLEVELNUMBERMASK; } @@ -198,10 +198,10 @@ public: struct WatcherWithUserData { DocWatcher *watcher; void *userData; - WatcherWithUserData(DocWatcher *watcher_=nullptr, void *userData_=nullptr) : + WatcherWithUserData(DocWatcher *watcher_=nullptr, void *userData_=nullptr) noexcept : watcher(watcher_), userData(userData_) { } - bool operator==(const WatcherWithUserData &other) const { + bool operator==(const WatcherWithUserData &other) const noexcept { return (watcher == other.watcher) && (userData == other.userData); } }; @@ -312,11 +312,11 @@ public: bool IsDBCSLeadByteInvalid(char ch) const noexcept; bool IsDBCSTrailByteInvalid(char ch) const noexcept; int DBCSDrawBytes(std::string_view text) const noexcept; - int SafeSegment(const char *text, int length, int lengthSegment) const; - EncodingFamily CodePageFamily() const; + int SafeSegment(const char *text, int length, int lengthSegment) const noexcept; + EncodingFamily CodePageFamily() const noexcept; // Gateways to modifying document - void ModifiedAt(Sci::Position pos); + void ModifiedAt(Sci::Position pos) noexcept; void CheckReadOnly(); bool DeleteChars(Sci::Position pos, Sci::Position len); Sci::Position InsertString(Sci::Position position, const char *s, Sci::Position insertLength); @@ -370,7 +370,7 @@ public: cb.GetCharRange(buffer, position, lengthRetrieve); } char SCI_METHOD StyleAt(Sci_Position position) const override { return cb.StyleAt(position); } - int StyleIndexAt(Sci_Position position) const { return static_cast<unsigned char>(cb.StyleAt(position)); } + int StyleIndexAt(Sci_Position position) const noexcept { return static_cast<unsigned char>(cb.StyleAt(position)); } void GetStyleRange(unsigned char *buffer, Sci::Position position, Sci::Position lengthRetrieve) const { cb.GetStyleRange(buffer, position, lengthRetrieve); } @@ -410,11 +410,11 @@ public: bool IsWordAt(Sci::Position start, Sci::Position end) const; bool MatchesWordOptions(bool word, bool wordStart, Sci::Position pos, Sci::Position length) const; - bool HasCaseFolder() const; + bool HasCaseFolder() const noexcept; void SetCaseFolder(CaseFolder *pcf_); Sci::Position FindText(Sci::Position minPos, Sci::Position maxPos, const char *search, int flags, Sci::Position *length); const char *SubstituteByPosition(const char *text, Sci::Position *length); - Sci::Line LinesTotal() const; + Sci::Line LinesTotal() const noexcept; void SetDefaultCharClasses(bool includeWordClass); void SetCharClasses(const unsigned char *chars, CharClassify::cc newCharClass); @@ -422,12 +422,12 @@ public: void SCI_METHOD StartStyling(Sci_Position position) override; bool SCI_METHOD SetStyleFor(Sci_Position length, char style) override; bool SCI_METHOD SetStyles(Sci_Position length, const char *styles) override; - Sci::Position GetEndStyled() const { return endStyled; } + Sci::Position GetEndStyled() const noexcept { return endStyled; } void EnsureStyledTo(Sci::Position pos); void StyleToAdjustingLineDuration(Sci::Position pos); void LexerChanged(); - int GetStyleClock() const { return styleClock; } - void IncrementStyleClock(); + int GetStyleClock() const noexcept { return styleClock; } + void IncrementStyleClock() noexcept; void SCI_METHOD DecorationSetCurrentIndicator(int indicator) override; void SCI_METHOD DecorationFillRange(Sci_Position position, int value, Sci_Position fillLength) override; LexInterface *GetLexInterface() const; @@ -463,7 +463,7 @@ public: bool IsWhiteLine(Sci::Line line) const; Sci::Position ParaUp(Sci::Position pos) const; Sci::Position ParaDown(Sci::Position pos) const; - int IndentSize() const { return actualIndentInChars; } + int IndentSize() const noexcept { return actualIndentInChars; } Sci::Position BraceMatch(Sci::Position position, Sci::Position maxReStyle); private: @@ -487,7 +487,7 @@ public: pdoc->EndUndoAction(); } } - bool Needed() const { + bool Needed() const noexcept { return groupNeeded; } }; @@ -512,7 +512,7 @@ public: Sci::Position token; DocModification(int modificationType_, Sci::Position position_=0, Sci::Position length_=0, - Sci::Line linesAdded_=0, const char *text_=nullptr, Sci::Line line_=0) : + Sci::Line linesAdded_=0, const char *text_=nullptr, Sci::Line line_=0) noexcept : modificationType(modificationType_), position(position_), length(length_), @@ -524,7 +524,7 @@ public: annotationLinesAdded(0), token(0) {} - DocModification(int modificationType_, const Action &act, Sci::Line linesAdded_=0) : + DocModification(int modificationType_, const Action &act, Sci::Line linesAdded_=0) noexcept : modificationType(modificationType_), position(act.position), length(act.lenData), |