aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2022-07-29 11:16:28 +1000
committerNeil <nyamatongwe@gmail.com>2022-07-29 11:16:28 +1000
commite030b1d56785405cb35531758d603be88af9b487 (patch)
tree9a428393f7963d50a0b7557e7c77ac1be37c7bb3 /src
parent6e6641d4733903d3c365fd9348f3656ff7000ddf (diff)
downloadscintilla-mirror-e030b1d56785405cb35531758d603be88af9b487.tar.gz
Apply rule-of-zero to delete standard methods where possible as handled by
contained types. This allows flexibility as most lower-level data types can be moved and SplitVector and Partitioning of non-move-only types may be copied. CellBuffer still needs destructor due to incomplete type so retains all standard operations.
Diffstat (limited to 'src')
-rw-r--r--src/CellBuffer.cxx9
-rw-r--r--src/CellBuffer.h19
-rw-r--r--src/ContractionState.cxx9
-rw-r--r--src/Partitioning.h9
-rw-r--r--src/PerLine.cxx19
-rw-r--r--src/PerLine.h36
-rw-r--r--src/RunStyles.cxx4
-rw-r--r--src/RunStyles.h6
-rw-r--r--src/SparseVector.h6
-rw-r--r--src/SplitVector.h9
-rw-r--r--src/UniqueString.cxx2
-rw-r--r--src/UniqueString.h7
12 files changed, 4 insertions, 131 deletions
diff --git a/src/CellBuffer.cxx b/src/CellBuffer.cxx
index b84372cf2..9a509f2eb 100644
--- a/src/CellBuffer.cxx
+++ b/src/CellBuffer.cxx
@@ -329,9 +329,6 @@ Action::Action() noexcept {
mayCoalesce = false;
}
-Action::~Action() {
-}
-
void Action::Create(ActionType at_, Sci::Position position_, const char *data_, Sci::Position lenData_, bool mayCoalesce_) {
data = nullptr;
position = position_;
@@ -379,9 +376,6 @@ UndoHistory::UndoHistory() {
actions[currentAction].Create(ActionType::start);
}
-UndoHistory::~UndoHistory() {
-}
-
void UndoHistory::EnsureUndoRoom() {
// Have to test that there is room for 2 more actions in the array
// as two actions may be created by the calling function
@@ -598,8 +592,7 @@ CellBuffer::CellBuffer(bool hasStyles_, bool largeDocument_) :
plv = std::make_unique<LineVector<int>>();
}
-CellBuffer::~CellBuffer() {
-}
+CellBuffer::~CellBuffer() noexcept = default;
char CellBuffer::CharAt(Sci::Position position) const noexcept {
return substance.ValueAt(position);
diff --git a/src/CellBuffer.h b/src/CellBuffer.h
index d8914d7ba..727e14944 100644
--- a/src/CellBuffer.h
+++ b/src/CellBuffer.h
@@ -39,13 +39,6 @@ public:
bool mayCoalesce;
Action() noexcept;
- // Deleted so Action objects can not be copied.
- Action(const Action &other) = delete;
- Action &operator=(const Action &other) = delete;
- Action &operator=(const Action &&other) = delete;
- // Move constructor allows vector to be resized without reallocating.
- Action(Action &&other) noexcept = default;
- ~Action();
void Create(ActionType at_, Sci::Position position_=0, const char *data_=nullptr, Sci::Position lenData_=0, bool mayCoalesce_=true);
void Clear() noexcept;
};
@@ -65,12 +58,6 @@ class UndoHistory {
public:
UndoHistory();
- // Deleted so UndoHistory objects can not be copied.
- UndoHistory(const UndoHistory &) = delete;
- UndoHistory(UndoHistory &&) = delete;
- void operator=(const UndoHistory &) = delete;
- void operator=(UndoHistory &&) = delete;
- ~UndoHistory();
const char *AppendAction(ActionType at, Sci::Position position, const char *data, Sci::Position lengthData, bool &startSequence, bool mayCoalesce=true);
@@ -163,9 +150,9 @@ public:
// Deleted so CellBuffer objects can not be copied.
CellBuffer(const CellBuffer &) = delete;
CellBuffer(CellBuffer &&) = delete;
- void operator=(const CellBuffer &) = delete;
- void operator=(CellBuffer &&) = delete;
- ~CellBuffer();
+ CellBuffer &operator=(const CellBuffer &) = delete;
+ CellBuffer &operator=(CellBuffer &&) = delete;
+ ~CellBuffer() noexcept;
/// Retrieving positions outside the range of the buffer works and returns 0
char CharAt(Sci::Position position) const noexcept;
diff --git a/src/ContractionState.cxx b/src/ContractionState.cxx
index b64e044ab..b36e1ebd8 100644
--- a/src/ContractionState.cxx
+++ b/src/ContractionState.cxx
@@ -59,12 +59,6 @@ class ContractionState final : public IContractionState {
public:
ContractionState() noexcept;
- // Deleted so ContractionState objects can not be copied.
- ContractionState(const ContractionState &) = delete;
- void operator=(const ContractionState &) = delete;
- ContractionState(ContractionState &&) = delete;
- void operator=(ContractionState &&) = delete;
- ~ContractionState() override;
void Clear() noexcept override;
@@ -102,9 +96,6 @@ ContractionState<LINE>::ContractionState() noexcept : linesInDocument(1) {
}
template <typename LINE>
-ContractionState<LINE>::~ContractionState() = default;
-
-template <typename LINE>
void ContractionState<LINE>::EnsureData() {
if (OneToOne()) {
visible = std::make_unique<RunStyles<LINE, char>>();
diff --git a/src/Partitioning.h b/src/Partitioning.h
index 2836b66dd..17bc1998e 100644
--- a/src/Partitioning.h
+++ b/src/Partitioning.h
@@ -78,15 +78,6 @@ public:
body.Insert(1, 0); // This is the end of the first partition and will be the start of the second
}
- // Deleted so Partitioning objects can not be copied.
- Partitioning(const Partitioning &) = delete;
- Partitioning(Partitioning &&) = delete;
- Partitioning &operator=(const Partitioning &) = delete;
- Partitioning &operator=(Partitioning &&) = default;
-
- ~Partitioning() {
- }
-
T Partitions() const noexcept {
return static_cast<T>(body.Length())-1;
}
diff --git a/src/PerLine.cxx b/src/PerLine.cxx
index f3fddcf27..78f7c7dc5 100644
--- a/src/PerLine.cxx
+++ b/src/PerLine.cxx
@@ -34,10 +34,6 @@ using namespace Scintilla::Internal;
MarkerHandleSet::MarkerHandleSet() {
}
-MarkerHandleSet::~MarkerHandleSet() {
- mhList.clear();
-}
-
bool MarkerHandleSet::Empty() const noexcept {
return mhList.empty();
}
@@ -93,9 +89,6 @@ void MarkerHandleSet::CombineWith(MarkerHandleSet *other) noexcept {
mhList.splice_after(mhList.before_begin(), other->mhList);
}
-LineMarkers::~LineMarkers() {
-}
-
void LineMarkers::Init() {
markers.DeleteAll();
}
@@ -219,9 +212,6 @@ void LineMarkers::DeleteMarkFromHandle(int markerHandle) {
}
}
-LineLevels::~LineLevels() {
-}
-
void LineLevels::Init() {
levels.DeleteAll();
}
@@ -281,9 +271,6 @@ int LineLevels::GetLevel(Sci::Line line) const noexcept {
}
}
-LineState::~LineState() {
-}
-
void LineState::Init() {
lineStates.DeleteAll();
}
@@ -355,9 +342,6 @@ std::unique_ptr<char[]>AllocateAnnotation(size_t length, int style) {
}
-LineAnnotation::~LineAnnotation() {
-}
-
bool LineAnnotation::Empty() const noexcept {
return annotations.Length() == 0;
}
@@ -482,9 +466,6 @@ int LineAnnotation::Lines(Sci::Line line) const noexcept {
return 0;
}
-LineTabstops::~LineTabstops() {
-}
-
void LineTabstops::Init() {
tabstops.DeleteAll();
}
diff --git a/src/PerLine.h b/src/PerLine.h
index ef9e36932..5b57dcaa9 100644
--- a/src/PerLine.h
+++ b/src/PerLine.h
@@ -28,12 +28,6 @@ class MarkerHandleSet {
public:
MarkerHandleSet();
- // Deleted so MarkerHandleSet objects can not be copied.
- MarkerHandleSet(const MarkerHandleSet &) = delete;
- MarkerHandleSet(MarkerHandleSet &&) = delete;
- void operator=(const MarkerHandleSet &) = delete;
- void operator=(MarkerHandleSet &&) = delete;
- ~MarkerHandleSet();
bool Empty() const noexcept;
int MarkValue() const noexcept; ///< Bit set of marker numbers.
bool Contains(int handle) const noexcept;
@@ -51,12 +45,6 @@ class LineMarkers : public PerLine {
public:
LineMarkers() : handleCurrent(0) {
}
- // Deleted so LineMarkers objects can not be copied.
- LineMarkers(const LineMarkers &) = delete;
- LineMarkers(LineMarkers &&) = delete;
- void operator=(const LineMarkers &) = delete;
- void operator=(LineMarkers &&) = delete;
- ~LineMarkers() override;
void Init() override;
void InsertLine(Sci::Line line) override;
void InsertLines(Sci::Line line, Sci::Line lines) override;
@@ -78,12 +66,6 @@ class LineLevels : public PerLine {
public:
LineLevels() {
}
- // Deleted so LineLevels objects can not be copied.
- LineLevels(const LineLevels &) = delete;
- LineLevels(LineLevels &&) = delete;
- void operator=(const LineLevels &) = delete;
- void operator=(LineLevels &&) = delete;
- ~LineLevels() override;
void Init() override;
void InsertLine(Sci::Line line) override;
void InsertLines(Sci::Line line, Sci::Line lines) override;
@@ -100,12 +82,6 @@ class LineState : public PerLine {
public:
LineState() {
}
- // Deleted so LineState objects can not be copied.
- LineState(const LineState &) = delete;
- LineState(LineState &&) = delete;
- void operator=(const LineState &) = delete;
- void operator=(LineState &&) = delete;
- ~LineState() override;
void Init() override;
void InsertLine(Sci::Line line) override;
void InsertLines(Sci::Line line, Sci::Line lines) override;
@@ -121,12 +97,6 @@ class LineAnnotation : public PerLine {
public:
LineAnnotation() {
}
- // Deleted so LineAnnotation objects can not be copied.
- LineAnnotation(const LineAnnotation &) = delete;
- LineAnnotation(LineAnnotation &&) = delete;
- void operator=(const LineAnnotation &) = delete;
- void operator=(LineAnnotation &&) = delete;
- ~LineAnnotation() override;
[[nodiscard]] bool Empty() const noexcept;
void Init() override;
@@ -153,12 +123,6 @@ class LineTabstops : public PerLine {
public:
LineTabstops() {
}
- // Deleted so LineTabstops objects can not be copied.
- LineTabstops(const LineTabstops &) = delete;
- LineTabstops(LineTabstops &&) = delete;
- void operator=(const LineTabstops &) = delete;
- void operator=(LineTabstops &&) = delete;
- ~LineTabstops() override;
void Init() override;
void InsertLine(Sci::Line line) override;
void InsertLines(Sci::Line line, Sci::Line lines) override;
diff --git a/src/RunStyles.cxx b/src/RunStyles.cxx
index 37c76f921..5985bc960 100644
--- a/src/RunStyles.cxx
+++ b/src/RunStyles.cxx
@@ -86,10 +86,6 @@ RunStyles<DISTANCE, STYLE>::RunStyles() {
}
template <typename DISTANCE, typename STYLE>
-RunStyles<DISTANCE, STYLE>::~RunStyles() {
-}
-
-template <typename DISTANCE, typename STYLE>
DISTANCE RunStyles<DISTANCE, STYLE>::Length() const noexcept {
return starts.PositionFromPartition(starts.Partitions());
}
diff --git a/src/RunStyles.h b/src/RunStyles.h
index 76d75d75a..44367adf7 100644
--- a/src/RunStyles.h
+++ b/src/RunStyles.h
@@ -34,12 +34,6 @@ private:
void RemoveRunIfSameAsPrevious(DISTANCE run);
public:
RunStyles();
- // Deleted so RunStyles objects can not be copied.
- RunStyles(const RunStyles &) = delete;
- RunStyles(RunStyles &&) = delete;
- void operator=(const RunStyles &) = delete;
- void operator=(RunStyles &&) = delete;
- ~RunStyles();
DISTANCE Length() const noexcept;
STYLE ValueAt(DISTANCE position) const noexcept;
DISTANCE FindNextChange(DISTANCE position, DISTANCE end) const noexcept;
diff --git a/src/SparseVector.h b/src/SparseVector.h
index cc3fe1448..f8c35fdc5 100644
--- a/src/SparseVector.h
+++ b/src/SparseVector.h
@@ -31,12 +31,6 @@ public:
values = SplitVector<T>();
values.InsertEmpty(0, 2);
}
- // Deleted so SparseVector objects can not be copied.
- SparseVector(const SparseVector &) = delete;
- SparseVector(SparseVector &&) = delete;
- void operator=(const SparseVector &) = delete;
- void operator=(SparseVector &&) = delete;
- ~SparseVector() noexcept = default;
Sci::Position Length() const noexcept {
return starts.Length();
}
diff --git a/src/SplitVector.h b/src/SplitVector.h
index 6c5514a22..19b854f5a 100644
--- a/src/SplitVector.h
+++ b/src/SplitVector.h
@@ -74,15 +74,6 @@ public:
SplitVector(size_t growSize_=8) : empty(), lengthBody(0), part1Length(0), gapLength(0), growSize(growSize_) {
}
- // Deleted so SplitVector objects can not be copied.
- SplitVector(const SplitVector &) = delete;
- SplitVector(SplitVector &&) = delete;
- SplitVector &operator=(const SplitVector &) = delete;
- SplitVector &operator=(SplitVector &&) = default;
-
- ~SplitVector() {
- }
-
size_t GetGrowSize() const noexcept {
return growSize;
}
diff --git a/src/UniqueString.cxx b/src/UniqueString.cxx
index 0550a0b8c..4c5b4b231 100644
--- a/src/UniqueString.cxx
+++ b/src/UniqueString.cxx
@@ -30,8 +30,6 @@ UniqueString UniqueStringCopy(const char *text) {
UniqueStringSet::UniqueStringSet() = default;
-UniqueStringSet::~UniqueStringSet() noexcept = default;
-
void UniqueStringSet::Clear() noexcept {
strings.clear();
}
diff --git a/src/UniqueString.h b/src/UniqueString.h
index 8d611992c..c5617e1c9 100644
--- a/src/UniqueString.h
+++ b/src/UniqueString.h
@@ -30,13 +30,6 @@ private:
std::vector<UniqueString> strings;
public:
UniqueStringSet();
- // UniqueStringSet objects can not be copied.
- UniqueStringSet(const UniqueStringSet &) = delete;
- UniqueStringSet &operator=(const UniqueStringSet &) = delete;
- // UniqueStringSet objects can be moved.
- UniqueStringSet(UniqueStringSet &&) = default;
- UniqueStringSet &operator=(UniqueStringSet &&) = default;
- ~UniqueStringSet() noexcept;
void Clear() noexcept;
const char *Save(const char *text);
};