diff options
author | Neil <nyamatongwe@gmail.com> | 2025-02-07 08:18:53 +1100 |
---|---|---|
committer | Neil <nyamatongwe@gmail.com> | 2025-02-07 08:18:53 +1100 |
commit | 2d14f22ef515b936e119940e7738ad1e08fcd2c7 (patch) | |
tree | 723c48154981d4aa0c3528a4aed332cff0d011fd /src | |
parent | 81efed752df3a07ce187f13667a05fe141075a29 (diff) | |
download | scintilla-mirror-2d14f22ef515b936e119940e7738ad1e08fcd2c7.tar.gz |
Use operator== inside <= and >= to shorten code.
Drop else after return in asymmetric cases to clarify the returned value.
Diffstat (limited to 'src')
-rw-r--r-- | src/Selection.cxx | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/src/Selection.cxx b/src/Selection.cxx index 527a9d29a..0de60a958 100644 --- a/src/Selection.cxx +++ b/src/Selection.cxx @@ -81,22 +81,19 @@ void SelectionPosition::MoveForInsertDelete(bool insertion, Sci::Position startC bool SelectionPosition::operator >(const SelectionPosition &other) const noexcept { if (position == other.position) return virtualSpace > other.virtualSpace; - else - return position > other.position; + return position > other.position; } bool SelectionPosition::operator <=(const SelectionPosition &other) const noexcept { - if (position == other.position && virtualSpace == other.virtualSpace) + if (other == *this) return true; - else - return other > *this; + return other > *this; } bool SelectionPosition::operator >=(const SelectionPosition &other) const noexcept { - if (position == other.position && virtualSpace == other.virtualSpace) + if (other == *this) return true; - else - return *this > other; + return *this > other; } std::string SelectionPosition::ToString() const { @@ -215,9 +212,8 @@ bool SelectionRange::Trim(SelectionRange range) noexcept { caret = end; } return Empty(); - } else { - return false; } + return false; } void SelectionRange::Truncate(Sci::Position length) noexcept { @@ -338,9 +334,8 @@ SelectionSegment Selection::Limits() const noexcept { SelectionSegment Selection::LimitsForRectangularElseMain() const noexcept { if (IsRectangular()) { return Limits(); - } else { - return ranges[mainRange].AsSegment(); } + return ranges[mainRange].AsSegment(); } size_t Selection::Count() const noexcept { @@ -375,9 +370,8 @@ const SelectionRange &Selection::RangeMain() const noexcept { SelectionPosition Selection::Start() const noexcept { if (IsRectangular()) { return rangeRectangular.Start(); - } else { - return ranges[mainRange].Start(); } + return ranges[mainRange].Start(); } bool Selection::MoveExtends() const noexcept { |