aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Document.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'src/Document.cxx')
-rw-r--r--src/Document.cxx36
1 files changed, 17 insertions, 19 deletions
diff --git a/src/Document.cxx b/src/Document.cxx
index 05f80640c..5dd64eed9 100644
--- a/src/Document.cxx
+++ b/src/Document.cxx
@@ -2373,7 +2373,7 @@ Sci::Position Document::FindText(Sci::Position minPos, Sci::Position maxPos, con
constexpr size_t maxFoldingExpansion = 4;
std::vector<char> searchThing((lengthFind+1) * UTF8MaxBytes * maxFoldingExpansion + 1);
const size_t lenSearch =
- pcf->Fold(&searchThing[0], searchThing.size(), search, lengthFind);
+ pcf->Fold(searchThing.data(), searchThing.size(), search, lengthFind);
while (forward ? (pos < endPos) : (pos >= endPos)) {
int widthFirstCharacter = 1;
Sci::Position posIndexDocument = pos;
@@ -2406,7 +2406,7 @@ Sci::Position Document::FindText(Sci::Position minPos, Sci::Position maxPos, con
// memcmp may examine lenFlat bytes in both arguments so assert it doesn't read past end of searchThing
assert((indexSearch + lenFlat) <= searchThing.size());
// Does folded match the buffer
- characterMatches = 0 == memcmp(folded, &searchThing[0] + indexSearch, lenFlat);
+ characterMatches = 0 == memcmp(folded, searchThing.data() + indexSearch, lenFlat);
}
if (!characterMatches) {
break;
@@ -2432,7 +2432,7 @@ Sci::Position Document::FindText(Sci::Position minPos, Sci::Position maxPos, con
constexpr size_t maxBytesCharacter = 2;
constexpr size_t maxFoldingExpansion = 4;
std::vector<char> searchThing((lengthFind+1) * maxBytesCharacter * maxFoldingExpansion + 1);
- const size_t lenSearch = pcf->Fold(&searchThing[0], searchThing.size(), search, lengthFind);
+ const size_t lenSearch = pcf->Fold(searchThing.data(), searchThing.size(), search, lengthFind);
while (forward ? (pos < endPos) : (pos >= endPos)) {
int widthFirstCharacter = 0;
Sci::Position indexDocument = 0;
@@ -2461,7 +2461,7 @@ Sci::Position Document::FindText(Sci::Position minPos, Sci::Position maxPos, con
// memcmp may examine lenFlat bytes in both arguments so assert it doesn't read past end of searchThing
assert((indexSearch + lenFlat) <= searchThing.size());
// Does folded match the buffer
- characterMatches = 0 == memcmp(folded, &searchThing[0] + indexSearch, lenFlat);
+ characterMatches = 0 == memcmp(folded, searchThing.data() + indexSearch, lenFlat);
}
if (!characterMatches) {
break;
@@ -2486,7 +2486,7 @@ Sci::Position Document::FindText(Sci::Position minPos, Sci::Position maxPos, con
} else {
const Sci::Position endSearch = (startPos <= endPos) ? endPos - lengthFind + 1 : endPos;
std::vector<char> searchThing(lengthFind + 1);
- pcf->Fold(&searchThing[0], searchThing.size(), search, lengthFind);
+ pcf->Fold(searchThing.data(), searchThing.size(), search, lengthFind);
while (forward ? (pos < endSearch) : (pos >= endSearch)) {
bool found = (pos + lengthFind) <= limitPos;
for (int indexSearch = 0; (indexSearch < lengthFind) && found; indexSearch++) {
@@ -3088,7 +3088,7 @@ public:
lineRangeEnd = doc->SciLineFromPosition(endPos);
lineRangeBreak = lineRangeEnd + increment;
}
- Range LineRange(Sci::Line line, Sci::Position lineStartPos, Sci::Position lineEndPos) const noexcept {
+ [[nodiscard]] Range LineRange(Sci::Line line, Sci::Position lineStartPos, Sci::Position lineEndPos) const noexcept {
Range range(lineStartPos, lineEndPos);
if (increment == 1) {
if (line == lineRangeStart)
@@ -3114,13 +3114,13 @@ public:
pdoc(pdoc_), end(end_) {
}
- char CharAt(Sci::Position index) const noexcept override {
+ [[nodiscard]] char CharAt(Sci::Position index) const noexcept override {
if (index < 0 || index >= end)
return 0;
else
return pdoc->CharAt(index);
}
- Sci::Position MovePositionOutsideChar(Sci::Position pos, Sci::Position moveDir) const noexcept override {
+ [[nodiscard]] Sci::Position MovePositionOutsideChar(Sci::Position pos, Sci::Position moveDir) const noexcept override {
return pdoc->MovePositionOutsideChar(pos, moveDir, false);
}
};
@@ -3163,10 +3163,10 @@ public:
bool operator!=(const ByteIterator &other) const noexcept {
return doc != other.doc || position != other.position;
}
- Sci::Position Pos() const noexcept {
+ [[nodiscard]] Sci::Position Pos() const noexcept {
return position;
}
- Sci::Position PosRoundUp() const noexcept {
+ [[nodiscard]] Sci::Position PosRoundUp() const noexcept {
return position;
}
};
@@ -3191,11 +3191,11 @@ class UTF8Iterator {
// These 3 fields determine the iterator position and are used for comparisons
const Document *doc;
Sci::Position position;
- size_t characterIndex;
+ size_t characterIndex = 0;
// Remaining fields are derived from the determining fields so are excluded in comparisons
- unsigned int lenBytes;
- size_t lenCharacters;
- wchar_t buffered[2];
+ unsigned int lenBytes = 0;
+ size_t lenCharacters = 0;
+ wchar_t buffered[2]{};
public:
using iterator_category = std::bidirectional_iterator_tag;
using value_type = wchar_t;
@@ -3204,9 +3204,7 @@ public:
using reference = wchar_t&;
explicit UTF8Iterator(const Document *doc_=nullptr, Sci::Position position_=0) noexcept :
- doc(doc_), position(position_), characterIndex(0), lenBytes(0), lenCharacters(0), buffered{} {
- buffered[0] = 0;
- buffered[1] = 0;
+ doc(doc_), position(position_) {
if (doc) {
ReadCharacter();
}
@@ -3258,10 +3256,10 @@ public:
position != other.position ||
characterIndex != other.characterIndex;
}
- Sci::Position Pos() const noexcept {
+ [[nodiscard]] Sci::Position Pos() const noexcept {
return position;
}
- Sci::Position PosRoundUp() const noexcept {
+ [[nodiscard]] Sci::Position PosRoundUp() const noexcept {
if (characterIndex)
return position + lenBytes; // Force to end of character
else