diff options
author | Neil <nyamatongwe@gmail.com> | 2020-06-11 10:08:29 +1000 |
---|---|---|
committer | Neil <nyamatongwe@gmail.com> | 2020-06-11 10:08:29 +1000 |
commit | a2931677c6e28aad5ddd56d82e5a8814746dc5fd (patch) | |
tree | d8c143a1ebcb4e91717d241c38ec43bf1da9e6ac /src/PositionCache.cxx | |
parent | b34e1a6efefd7b39f14daa867510b2e2d453a0bb (diff) | |
download | scintilla-mirror-a2931677c6e28aad5ddd56d82e5a8814746dc5fd.tar.gz |
Use noexcept where safe and maintainable.
Diffstat (limited to 'src/PositionCache.cxx')
-rw-r--r-- | src/PositionCache.cxx | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/PositionCache.cxx b/src/PositionCache.cxx index 7452a0f29..28d2632fe 100644 --- a/src/PositionCache.cxx +++ b/src/PositionCache.cxx @@ -108,12 +108,12 @@ void LineLayout::Free() noexcept { bidiData.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) { @@ -123,7 +123,7 @@ int LineLayout::LineStart(int line) const { } } -int Scintilla::LineLayout::LineLength(int line) const { +int Scintilla::LineLayout::LineLength(int line) const noexcept { if (!lineStarts) { return numCharsInLine; } if (line >= lines - 1) { @@ -133,7 +133,7 @@ int Scintilla::LineLayout::LineLength(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) { @@ -143,16 +143,16 @@ 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))); } -int LineLayout::SubLineFromPosition(int posInLine, PointEnd pe) const { +int LineLayout::SubLineFromPosition(int posInLine, PointEnd pe) const noexcept { if (!lineStarts || (posInLine > maxLineLength)) { return lines - 1; } @@ -225,7 +225,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 { @@ -241,7 +241,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) { @@ -258,7 +258,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) { @@ -287,7 +287,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]; } @@ -397,7 +397,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) { @@ -478,7 +478,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++) { @@ -710,7 +710,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++) { |