diff options
author | Neil <nyamatongwe@gmail.com> | 2020-03-24 23:04:11 +1100 |
---|---|---|
committer | Neil <nyamatongwe@gmail.com> | 2020-03-24 23:04:11 +1100 |
commit | c98b190d47f6adb869305baf6ee8447de79d463e (patch) | |
tree | 3781eadab4fc513ed7bbf509de7ac609af5fd57e /src/CellBuffer.cxx | |
parent | ae9dd542f45fb64c97361737dd9d4896949644c8 (diff) | |
download | scintilla-mirror-c98b190d47f6adb869305baf6ee8447de79d463e.tar.gz |
Use noexcept where possible.
Diffstat (limited to 'src/CellBuffer.cxx')
-rw-r--r-- | src/CellBuffer.cxx | 42 |
1 files changed, 23 insertions, 19 deletions
diff --git a/src/CellBuffer.cxx b/src/CellBuffer.cxx index 80dc02d64..74fb74816 100644 --- a/src/CellBuffer.cxx +++ b/src/CellBuffer.cxx @@ -62,16 +62,16 @@ struct CountWidths { class ILineVector { public: virtual void Init() = 0; - virtual void SetPerLine(PerLine *pl) = 0; - virtual void InsertText(Sci::Line line, Sci::Position delta) = 0; + virtual void SetPerLine(PerLine *pl) noexcept = 0; + virtual void InsertText(Sci::Line line, Sci::Position delta) noexcept = 0; virtual void InsertLine(Sci::Line line, Sci::Position position, bool lineStart) = 0; virtual void SetLineStart(Sci::Line line, Sci::Position position) noexcept = 0; virtual void RemoveLine(Sci::Line line) = 0; virtual Sci::Line Lines() const noexcept = 0; virtual Sci::Line LineFromPosition(Sci::Position pos) const noexcept = 0; virtual Sci::Position LineStart(Sci::Line line) const noexcept = 0; - virtual void InsertCharacters(Sci::Line line, CountWidths delta) = 0; - virtual void SetLineCharactersWidth(Sci::Line line, CountWidths width) = 0; + virtual void InsertCharacters(Sci::Line line, CountWidths delta) noexcept = 0; + virtual void SetLineCharactersWidth(Sci::Line line, CountWidths width) noexcept = 0; virtual int LineCharacterIndex() const noexcept = 0; virtual bool AllocateLineCharacterIndex(int lineCharacterIndex, Sci::Line lines) = 0; virtual bool ReleaseLineCharacterIndex(int lineCharacterIndex) = 0; @@ -124,7 +124,7 @@ public: return starts.PositionFromPartition(static_cast<POS>(line) + 1) - starts.PositionFromPartition(static_cast<POS>(line)); } - void SetLineWidth(Sci::Line line, Sci::Position width) { + void SetLineWidth(Sci::Line line, Sci::Position width) noexcept { const Sci::Position widthCurrent = LineWidth(line); starts.InsertText(static_cast<POS>(line), static_cast<POS>(width - widthCurrent)); } @@ -154,10 +154,10 @@ public: startsUTF32.starts.DeleteAll(); startsUTF16.starts.DeleteAll(); } - void SetPerLine(PerLine *pl) override { + void SetPerLine(PerLine *pl) noexcept override { perLine = pl; } - void InsertText(Sci::Line line, Sci::Position delta) override { + void InsertText(Sci::Line line, Sci::Position delta) noexcept override { starts.InsertText(static_cast<POS>(line), static_cast<POS>(delta)); } void InsertLine(Sci::Line line, Sci::Position position, bool lineStart) override { @@ -201,7 +201,7 @@ public: Sci::Position LineStart(Sci::Line line) const noexcept override { return starts.PositionFromPartition(static_cast<POS>(line)); } - void InsertCharacters(Sci::Line line, CountWidths delta) override { + void InsertCharacters(Sci::Line line, CountWidths delta) noexcept override { if (startsUTF32.Active()) { startsUTF32.starts.InsertText(static_cast<POS>(line), static_cast<POS>(delta.WidthUTF32())); } @@ -209,7 +209,7 @@ public: startsUTF16.starts.InsertText(static_cast<POS>(line), static_cast<POS>(delta.WidthUTF16())); } } - void SetLineCharactersWidth(Sci::Line line, CountWidths width) override { + void SetLineCharactersWidth(Sci::Line line, CountWidths width) noexcept override { if (startsUTF32.Active()) { assert(startsUTF32.starts.Partitions() == starts.Partitions()); startsUTF32.SetLineWidth(line, width.WidthUTF32()); @@ -268,7 +268,7 @@ public: } }; -Action::Action() { +Action::Action() noexcept { at = startAction; position = 0; lenData = 0; @@ -290,7 +290,7 @@ void Action::Create(actionType at_, Sci::Position position_, const char *data_, mayCoalesce = mayCoalesce_; } -void Action::Clear() { +void Action::Clear() noexcept { data = nullptr; lenData = 0; } @@ -450,7 +450,7 @@ void UndoHistory::DeleteUndoHistory() { tentativePoint = -1; } -void UndoHistory::SetSavePoint() { +void UndoHistory::SetSavePoint() noexcept { savePoint = currentAction; } @@ -468,7 +468,11 @@ void UndoHistory::TentativeCommit() { maxAction = currentAction; } -int UndoHistory::TentativeSteps() { +bool UndoHistory::TentativeActive() const noexcept { + return tentativePoint >= 0; +} + +int UndoHistory::TentativeSteps() noexcept { // Drop any trailing startAction if (actions[currentAction].at == startAction && currentAction > 0) currentAction--; @@ -593,7 +597,7 @@ const char *CellBuffer::BufferPointer() { return substance.BufferPointer(); } -const char *CellBuffer::RangePointer(Sci::Position position, Sci::Position rangeLength) { +const char *CellBuffer::RangePointer(Sci::Position position, Sci::Position rangeLength) noexcept { return substance.RangePointer(position, rangeLength); } @@ -617,7 +621,7 @@ const char *CellBuffer::InsertString(Sci::Position position, const char *s, Sci: return data; } -bool CellBuffer::SetStyleAt(Sci::Position position, char styleValue) { +bool CellBuffer::SetStyleAt(Sci::Position position, char styleValue) noexcept { if (!hasStyles) { return false; } @@ -677,7 +681,7 @@ void CellBuffer::Allocate(Sci::Position newSize) { } } -void CellBuffer::SetUTF8Substance(bool utf8Substance_) { +void CellBuffer::SetUTF8Substance(bool utf8Substance_) noexcept { utf8Substance = utf8Substance_; } @@ -709,7 +713,7 @@ bool CellBuffer::ContainsLineEnd(const char *s, Sci::Position length) const noex return false; } -void CellBuffer::SetPerLine(PerLine *pl) { +void CellBuffer::SetPerLine(PerLine *pl) noexcept { plv->SetPerLine(pl); } @@ -759,7 +763,7 @@ bool CellBuffer::IsReadOnly() const noexcept { return readOnly; } -void CellBuffer::SetReadOnly(bool set) { +void CellBuffer::SetReadOnly(bool set) noexcept { readOnly = set; } @@ -787,7 +791,7 @@ void CellBuffer::TentativeCommit() { uh.TentativeCommit(); } -int CellBuffer::TentativeSteps() { +int CellBuffer::TentativeSteps() noexcept { return uh.TentativeSteps(); } |