diff options
| author | Neil <nyamatongwe@gmail.com> | 2019-04-28 09:41:51 +1000 | 
|---|---|---|
| committer | Neil <nyamatongwe@gmail.com> | 2019-04-28 09:41:51 +1000 | 
| commit | 3fbb0e2d513e923f481879c1ce96aacd33f2b8c6 (patch) | |
| tree | 8aaf85650ea16ab34a6c563f7f1f6ac3fa7fa05e /src/Selection.cxx | |
| parent | 6a542f10f35a7f6182335250ac6fb25dbd230cac (diff) | |
| download | scintilla-mirror-3fbb0e2d513e923f481879c1ce96aacd33f2b8c6.tar.gz | |
Remove noexcept from Selection constructor as it allocates memory.
Add noexcept to reader methods and simple writer methods on Selection classes.
Diffstat (limited to 'src/Selection.cxx')
| -rw-r--r-- | src/Selection.cxx | 58 | 
1 files changed, 29 insertions, 29 deletions
| diff --git a/src/Selection.cxx b/src/Selection.cxx index 105b93315..9b08ea001 100644 --- a/src/Selection.cxx +++ b/src/Selection.cxx @@ -23,7 +23,7 @@  using namespace Scintilla; -void SelectionPosition::MoveForInsertDelete(bool insertion, Sci::Position startChange, Sci::Position length) { +void SelectionPosition::MoveForInsertDelete(bool insertion, Sci::Position startChange, Sci::Position length) noexcept {  	if (insertion) {  		if (position == startChange) {  			const Sci::Position virtualLengthRemove = std::min(length, virtualSpace); @@ -48,35 +48,35 @@ void SelectionPosition::MoveForInsertDelete(bool insertion, Sci::Position startC  	}  } -bool SelectionPosition::operator <(const SelectionPosition &other) const { +bool SelectionPosition::operator <(const SelectionPosition &other) const noexcept {  	if (position == other.position)  		return virtualSpace < other.virtualSpace;  	else  		return position < other.position;  } -bool SelectionPosition::operator >(const SelectionPosition &other) const { +bool SelectionPosition::operator >(const SelectionPosition &other) const noexcept {  	if (position == other.position)  		return virtualSpace > other.virtualSpace;  	else  		return position > other.position;  } -bool SelectionPosition::operator <=(const SelectionPosition &other) const { +bool SelectionPosition::operator <=(const SelectionPosition &other) const noexcept {  	if (position == other.position && virtualSpace == other.virtualSpace)  		return true;  	else  		return other > *this;  } -bool SelectionPosition::operator >=(const SelectionPosition &other) const { +bool SelectionPosition::operator >=(const SelectionPosition &other) const noexcept {  	if (position == other.position && virtualSpace == other.virtualSpace)  		return true;  	else  		return *this > other;  } -Sci::Position SelectionRange::Length() const { +Sci::Position SelectionRange::Length() const noexcept {  	if (anchor > caret) {  		return anchor.Position() - caret.Position();  	} else { @@ -84,33 +84,33 @@ Sci::Position SelectionRange::Length() const {  	}  } -void SelectionRange::MoveForInsertDelete(bool insertion, Sci::Position startChange, Sci::Position length) { +void SelectionRange::MoveForInsertDelete(bool insertion, Sci::Position startChange, Sci::Position length) noexcept {  	caret.MoveForInsertDelete(insertion, startChange, length);  	anchor.MoveForInsertDelete(insertion, startChange, length);  } -bool SelectionRange::Contains(Sci::Position pos) const { +bool SelectionRange::Contains(Sci::Position pos) const noexcept {  	if (anchor > caret)  		return (pos >= caret.Position()) && (pos <= anchor.Position());  	else  		return (pos >= anchor.Position()) && (pos <= caret.Position());  } -bool SelectionRange::Contains(SelectionPosition sp) const { +bool SelectionRange::Contains(SelectionPosition sp) const noexcept {  	if (anchor > caret)  		return (sp >= caret) && (sp <= anchor);  	else  		return (sp >= anchor) && (sp <= caret);  } -bool SelectionRange::ContainsCharacter(Sci::Position posCharacter) const { +bool SelectionRange::ContainsCharacter(Sci::Position posCharacter) const noexcept {  	if (anchor > caret)  		return (posCharacter >= caret.Position()) && (posCharacter < anchor.Position());  	else  		return (posCharacter >= anchor.Position()) && (posCharacter < caret.Position());  } -SelectionSegment SelectionRange::Intersect(SelectionSegment check) const { +SelectionSegment SelectionRange::Intersect(SelectionSegment check) const noexcept {  	const SelectionSegment inOrder(caret, anchor);  	if ((inOrder.start <= check.end) || (inOrder.end >= check.start)) {  		SelectionSegment portion = check; @@ -127,11 +127,11 @@ SelectionSegment SelectionRange::Intersect(SelectionSegment check) const {  	}  } -void SelectionRange::Swap() { +void SelectionRange::Swap() noexcept {  	std::swap(caret, anchor);  } -bool SelectionRange::Trim(SelectionRange range) { +bool SelectionRange::Trim(SelectionRange range) noexcept {  	const SelectionPosition startRange = range.Start();  	const SelectionPosition endRange = range.End();  	SelectionPosition start = Start(); @@ -167,7 +167,7 @@ bool SelectionRange::Trim(SelectionRange range) {  }  // If range is all virtual collapse to start of virtual space -void SelectionRange::MinimizeVirtualSpace() { +void SelectionRange::MinimizeVirtualSpace() noexcept {  	if (caret.Position() == anchor.Position()) {  		Sci::Position virtualSpace = caret.VirtualSpace();  		if (virtualSpace > anchor.VirtualSpace()) @@ -177,14 +177,14 @@ void SelectionRange::MinimizeVirtualSpace() {  	}  } -Selection::Selection() noexcept : mainRange(0), moveExtends(false), tentativeMain(false), selType(selStream) { +Selection::Selection() : mainRange(0), moveExtends(false), tentativeMain(false), selType(selStream) {  	AddSelection(SelectionRange(SelectionPosition(0)));  }  Selection::~Selection() {  } -bool Selection::IsRectangular() const { +bool Selection::IsRectangular() const noexcept {  	return (selType == selRectangle) || (selType == selThin);  } @@ -196,7 +196,7 @@ Sci::Position Selection::MainAnchor() const {  	return ranges[mainRange].anchor.Position();  } -SelectionRange &Selection::Rectangular() { +SelectionRange &Selection::Rectangular() noexcept {  	return rangeRectangular;  } @@ -221,15 +221,15 @@ SelectionSegment Selection::LimitsForRectangularElseMain() const {  	}  } -size_t Selection::Count() const { +size_t Selection::Count() const noexcept {  	return ranges.size();  } -size_t Selection::Main() const { +size_t Selection::Main() const noexcept {  	return mainRange;  } -void Selection::SetMain(size_t r) { +void Selection::SetMain(size_t r) noexcept {  	PLATFORM_ASSERT(r < ranges.size());  	mainRange = r;  } @@ -258,15 +258,15 @@ SelectionPosition Selection::Start() const {  	}  } -bool Selection::MoveExtends() const { +bool Selection::MoveExtends() const noexcept {  	return moveExtends;  } -void Selection::SetMoveExtends(bool moveExtends_) { +void Selection::SetMoveExtends(bool moveExtends_) noexcept {  	moveExtends = moveExtends_;  } -bool Selection::Empty() const { +bool Selection::Empty() const noexcept {  	for (const SelectionRange &range : ranges) {  		if (!range.Empty())  			return false; @@ -274,7 +274,7 @@ bool Selection::Empty() const {  	return true;  } -SelectionPosition Selection::Last() const { +SelectionPosition Selection::Last() const noexcept {  	SelectionPosition lastPosition;  	for (const SelectionRange &range : ranges) {  		if (lastPosition < range.caret) @@ -285,7 +285,7 @@ SelectionPosition Selection::Last() const {  	return lastPosition;  } -Sci::Position Selection::Length() const { +Sci::Position Selection::Length() const noexcept {  	Sci::Position len = 0;  	for (const SelectionRange &range : ranges) {  		len += range.Length(); @@ -293,7 +293,7 @@ Sci::Position Selection::Length() const {  	return len;  } -void Selection::MovePositions(bool insertion, Sci::Position startChange, Sci::Position length) { +void Selection::MovePositions(bool insertion, Sci::Position startChange, Sci::Position length) noexcept {  	for (SelectionRange &range : ranges) {  		range.MoveForInsertDelete(insertion, startChange, length);  	} @@ -372,7 +372,7 @@ void Selection::TentativeSelection(SelectionRange range) {  	tentativeMain = true;  } -void Selection::CommitTentative() { +void Selection::CommitTentative() noexcept {  	rangesSaved.clear();  	tentativeMain = false;  } @@ -393,7 +393,7 @@ int Selection::InSelectionForEOL(Sci::Position pos) const {  	return 0;  } -Sci::Position Selection::VirtualSpaceFor(Sci::Position pos) const { +Sci::Position Selection::VirtualSpaceFor(Sci::Position pos) const noexcept {  	Sci::Position virtualSpace = 0;  	for (const SelectionRange &range : ranges) {  		if ((range.caret.Position() == pos) && (virtualSpace < range.caret.VirtualSpace())) @@ -431,7 +431,7 @@ void Selection::RemoveDuplicates() {  	}  } -void Selection::RotateMain() { +void Selection::RotateMain() noexcept {  	mainRange = (mainRange + 1) % ranges.size();  } | 
