aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2025-05-03 10:31:42 +1000
committerNeil <nyamatongwe@gmail.com>2025-05-03 10:31:42 +1000
commitf853a1db0e9bf7afa93e806fd5df7ae35a624b9a (patch)
tree6a3a96bb3771f75b269cd8ea3152f0cb89178b65 /src
parent0355d3ca4a6c9c075e933757deda4e423b873b5c (diff)
downloadscintilla-mirror-f853a1db0e9bf7afa93e806fd5df7ae35a624b9a.tar.gz
Use noexcept, emplace_back, avoid a cast, and simplify code.
Diffstat (limited to 'src')
-rw-r--r--src/Editor.cxx15
-rw-r--r--src/Editor.h4
2 files changed, 10 insertions, 9 deletions
diff --git a/src/Editor.cxx b/src/Editor.cxx
index 51cd2c39e..89cf544ab 100644
--- a/src/Editor.cxx
+++ b/src/Editor.cxx
@@ -623,7 +623,7 @@ void Editor::InvalidateWholeSelection() {
/* For Line selection - the anchor and caret are always
at the beginning and end of the region lines. */
-SelectionRange Editor::LineSelectionRange(SelectionPosition currentPos_, SelectionPosition anchor_) const {
+SelectionRange Editor::LineSelectionRange(SelectionPosition currentPos_, SelectionPosition anchor_) const noexcept {
if (currentPos_ > anchor_) {
anchor_ = SelectionPosition(pdoc->LineStartPosition(anchor_.Position()));
currentPos_ = SelectionPosition(pdoc->LineEndPosition(currentPos_.Position()));
@@ -740,9 +740,9 @@ void Editor::MultipleSelectAdd(AddNumber addNumber) {
// Common case is that the selection is completely within the target but
// may also have overlap at start or end.
if (rangeMainSelection.end < rangeTarget.end)
- searchRanges.push_back(Range(rangeMainSelection.end, rangeTarget.end));
+ searchRanges.emplace_back(rangeMainSelection.end, rangeTarget.end);
if (rangeTarget.start < rangeMainSelection.start)
- searchRanges.push_back(Range(rangeTarget.start, rangeMainSelection.start));
+ searchRanges.emplace_back(rangeTarget.start, rangeMainSelection.start);
} else {
// No overlap
searchRanges.push_back(rangeTarget);
@@ -1539,7 +1539,7 @@ bool Editor::WrapBlock(Surface *surface, Sci::Line lineToWrap, Sci::Line lineToW
std::vector<int> linesAfterWrap(linesBeingWrapped);
- size_t threads = std::min<size_t>({ linesBeingWrapped, view.maxLayoutThreads });
+ size_t threads = std::min<size_t>(linesBeingWrapped, view.maxLayoutThreads);
if (!surface->SupportsFeature(Supports::ThreadSafeMeasureWidths)) {
threads = 1;
}
@@ -4415,7 +4415,7 @@ std::string Editor::RangeText(Sci::Position start, Sci::Position end) const {
pdoc->GetCharRange(ret.data(), start, len);
return ret;
}
- return std::string();
+ return {};
}
bool Editor::CopyLineRange(SelectionText *ss, bool allowProtected) {
@@ -5684,7 +5684,7 @@ void Editor::FoldExpand(Sci::Line line, FoldAction action, FoldLevel level) {
Redraw();
}
-Sci::Line Editor::ContractedFoldNext(Sci::Line lineStart) const {
+Sci::Line Editor::ContractedFoldNext(Sci::Line lineStart) const noexcept {
for (Sci::Line line = lineStart; line<pdoc->LinesTotal();) {
if (!pcs->GetExpanded(line) && LevelIsHeader(pdoc->GetFoldLevel(line)))
return line;
@@ -8435,7 +8435,8 @@ sptr_t Editor::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) {
doc->Allocate(PositionFromUPtr(wParam));
doc->SetUndoCollection(false);
pcs = ContractionStateCreate(pdoc->IsLarge());
- return reinterpret_cast<sptr_t>(static_cast<ILoader *>(doc));
+ ILoader *loader = doc;
+ return reinterpret_cast<sptr_t>(loader);
}
case Message::SetModEventMask:
diff --git a/src/Editor.h b/src/Editor.h
index ff940bc49..46879cdc4 100644
--- a/src/Editor.h
+++ b/src/Editor.h
@@ -346,7 +346,7 @@ protected: // ScintillaBase subclass needs access to much of Editor
void ThinRectangularRange();
void InvalidateSelection(SelectionRange newMain, bool invalidateWholeSelection=false);
void InvalidateWholeSelection();
- SelectionRange LineSelectionRange(SelectionPosition currentPos_, SelectionPosition anchor_) const;
+ SelectionRange LineSelectionRange(SelectionPosition currentPos_, SelectionPosition anchor_) const noexcept;
void SetSelection(SelectionPosition currentPos_, SelectionPosition anchor_);
void SetSelection(Sci::Position currentPos_, Sci::Position anchor_);
void SetSelection(SelectionPosition currentPos_);
@@ -593,7 +593,7 @@ protected: // ScintillaBase subclass needs access to much of Editor
void SetFoldExpanded(Sci::Line lineDoc, bool expanded);
void FoldLine(Sci::Line line, Scintilla::FoldAction action);
void FoldExpand(Sci::Line line, Scintilla::FoldAction action, Scintilla::FoldLevel level);
- Sci::Line ContractedFoldNext(Sci::Line lineStart) const;
+ Sci::Line ContractedFoldNext(Sci::Line lineStart) const noexcept;
void EnsureLineVisible(Sci::Line lineDoc, bool enforcePolicy);
void FoldChanged(Sci::Line line, Scintilla::FoldLevel levelNow, Scintilla::FoldLevel levelPrev);
void NeedShown(Sci::Position pos, Sci::Position len);