aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/PositionCache.cxx
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2020-06-11 10:08:29 +1000
committerNeil <nyamatongwe@gmail.com>2020-06-11 10:08:29 +1000
commit877def4f243e1ef5eb39a6132f3969844e00be95 (patch)
tree5041a5f52f7d38c026d594f53d3fabc813205221 /src/PositionCache.cxx
parentc8136baf0e923ea16cb5e75d75539ca61129925a (diff)
downloadscintilla-mirror-877def4f243e1ef5eb39a6132f3969844e00be95.tar.gz
Backport: Use noexcept where safe and maintainable.
Backport of changeset 8300:266c8247814e.
Diffstat (limited to 'src/PositionCache.cxx')
-rw-r--r--src/PositionCache.cxx24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/PositionCache.cxx b/src/PositionCache.cxx
index 5a6d8dac0..5b9c2ddd4 100644
--- a/src/PositionCache.cxx
+++ b/src/PositionCache.cxx
@@ -90,12 +90,12 @@ void LineLayout::Free() noexcept {
lineStarts.reset();
}
-void LineLayout::Invalidate(validLevel validity_) {
+void LineLayout::Invalidate(validLevel validity_) noexcept {
if (validity > validity_)
validity = validity_;
}
-int LineLayout::LineStart(int line) const {
+int LineLayout::LineStart(int line) const noexcept {
if (line <= 0) {
return 0;
} else if ((line >= lines) || !lineStarts) {
@@ -105,7 +105,7 @@ int LineLayout::LineStart(int line) const {
}
}
-int LineLayout::LineLastVisible(int line, Scope scope) const {
+int LineLayout::LineLastVisible(int line, Scope scope) const noexcept {
if (line < 0) {
return 0;
} else if ((line >= lines-1) || !lineStarts) {
@@ -115,11 +115,11 @@ int LineLayout::LineLastVisible(int line, Scope scope) const {
}
}
-Range LineLayout::SubLineRange(int subLine, Scope scope) const {
+Range LineLayout::SubLineRange(int subLine, Scope scope) const noexcept {
return Range(LineStart(subLine), LineLastVisible(subLine, scope));
}
-bool LineLayout::InLine(int offset, int line) const {
+bool LineLayout::InLine(int offset, int line) const noexcept {
return ((offset >= LineStart(line)) && (offset < LineStart(line + 1))) ||
((offset == numCharsInLine) && (line == (lines-1)));
}
@@ -178,7 +178,7 @@ void LineLayout::RestoreBracesHighlight(Range rangeLine, const Sci::Position bra
xHighlightGuide = 0;
}
-int LineLayout::FindBefore(XYPOSITION x, Range range) const {
+int LineLayout::FindBefore(XYPOSITION x, Range range) const noexcept {
Sci::Position lower = range.start;
Sci::Position upper = range.end;
do {
@@ -194,7 +194,7 @@ int LineLayout::FindBefore(XYPOSITION x, Range range) const {
}
-int LineLayout::FindPositionFromX(XYPOSITION x, Range range, bool charPosition) const {
+int LineLayout::FindPositionFromX(XYPOSITION x, Range range, bool charPosition) const noexcept {
int pos = FindBefore(x, range);
while (pos < range.end) {
if (charPosition) {
@@ -211,7 +211,7 @@ int LineLayout::FindPositionFromX(XYPOSITION x, Range range, bool charPosition)
return static_cast<int>(range.end);
}
-Point LineLayout::PointFromPosition(int posInLine, int lineHeight, PointEnd pe) const {
+Point LineLayout::PointFromPosition(int posInLine, int lineHeight, PointEnd pe) const noexcept {
Point pt;
// In case of very long line put x at arbitrary large position
if (posInLine > maxLineLength) {
@@ -240,7 +240,7 @@ Point LineLayout::PointFromPosition(int posInLine, int lineHeight, PointEnd pe)
return pt;
}
-int LineLayout::EndLineStyle() const {
+int LineLayout::EndLineStyle() const noexcept {
return styles[numCharsBeforeEOL > 0 ? numCharsBeforeEOL-1 : 0];
}
@@ -289,7 +289,7 @@ void LineLayoutCache::Deallocate() noexcept {
cache.clear();
}
-void LineLayoutCache::Invalidate(LineLayout::validLevel validity_) {
+void LineLayoutCache::Invalidate(LineLayout::validLevel validity_) noexcept {
if (!cache.empty() && !allInvalidated) {
for (const std::unique_ptr<LineLayout> &ll : cache) {
if (ll) {
@@ -370,7 +370,7 @@ void LineLayoutCache::Dispose(LineLayout *ll) noexcept {
}
// Simply pack the (maximum 4) character bytes into an int
-static unsigned int KeyFromString(const char *charBytes, size_t len) {
+static unsigned int KeyFromString(const char *charBytes, size_t len) noexcept {
PLATFORM_ASSERT(len <= 4);
unsigned int k=0;
for (size_t i=0; i<len && charBytes[i]; i++) {
@@ -602,7 +602,7 @@ void PositionCacheEntry::Clear() noexcept {
}
bool PositionCacheEntry::Retrieve(unsigned int styleNumber_, const char *s_,
- unsigned int len_, XYPOSITION *positions_) const {
+ unsigned int len_, XYPOSITION *positions_) const noexcept {
if ((styleNumber == styleNumber_) && (len == len_) &&
(memcmp(&positions[len], s_, len)== 0)) {
for (unsigned int i=0; i<len; i++) {