diff options
author | Neil <nyamatongwe@gmail.com> | 2018-03-01 11:03:37 +1100 |
---|---|---|
committer | Neil <nyamatongwe@gmail.com> | 2018-03-01 11:03:37 +1100 |
commit | 1b808ad6a4e623c564513a72cedc17581426942f (patch) | |
tree | f0671c60ec9680f4c4d2e9f7e8c85028b833b0cf /src/PositionCache.cxx | |
parent | 13f7cab5a5894313d2245ae56d6f2e7b1f0d7307 (diff) | |
download | scintilla-mirror-1b808ad6a4e623c564513a72cedc17581426942f.tar.gz |
Backport: Mark variables as const where simple.
Backport of changeset 6470:d78a4b522662.
Diffstat (limited to 'src/PositionCache.cxx')
-rw-r--r-- | src/PositionCache.cxx | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/PositionCache.cxx b/src/PositionCache.cxx index 99e3c4d56..60dc3c070 100644 --- a/src/PositionCache.cxx +++ b/src/PositionCache.cxx @@ -143,14 +143,14 @@ void LineLayout::SetLineStart(int line, int start) { void LineLayout::SetBracesHighlight(Range rangeLine, const Sci::Position braces[], char bracesMatchStyle, int xHighlight, bool ignoreStyle) { if (!ignoreStyle && rangeLine.ContainsCharacter(braces[0])) { - int braceOffset = braces[0] - rangeLine.start; + const int braceOffset = braces[0] - rangeLine.start; if (braceOffset < numCharsInLine) { bracePreviousStyles[0] = styles[braceOffset]; styles[braceOffset] = bracesMatchStyle; } } if (!ignoreStyle && rangeLine.ContainsCharacter(braces[1])) { - int braceOffset = braces[1] - rangeLine.start; + const int braceOffset = braces[1] - rangeLine.start; if (braceOffset < numCharsInLine) { bracePreviousStyles[1] = styles[braceOffset]; styles[braceOffset] = bracesMatchStyle; @@ -164,13 +164,13 @@ void LineLayout::SetBracesHighlight(Range rangeLine, const Sci::Position braces[ void LineLayout::RestoreBracesHighlight(Range rangeLine, const Sci::Position braces[], bool ignoreStyle) { if (!ignoreStyle && rangeLine.ContainsCharacter(braces[0])) { - int braceOffset = braces[0] - rangeLine.start; + const int braceOffset = braces[0] - rangeLine.start; if (braceOffset < numCharsInLine) { styles[braceOffset] = bracePreviousStyles[0]; } } if (!ignoreStyle && rangeLine.ContainsCharacter(braces[1])) { - int braceOffset = braces[1] - rangeLine.start; + const int braceOffset = braces[1] - rangeLine.start; if (braceOffset < numCharsInLine) { styles[braceOffset] = bracePreviousStyles[1]; } @@ -180,7 +180,7 @@ void LineLayout::RestoreBracesHighlight(Range rangeLine, const Sci::Position bra int LineLayout::FindBefore(XYPOSITION x, int lower, int upper) const { do { - int middle = (upper + lower + 1) / 2; // Round high + const int middle = (upper + lower + 1) / 2; // Round high const XYPOSITION posMiddle = positions[middle]; if (x < posMiddle) { upper = middle - 1; @@ -491,7 +491,7 @@ BreakFinder::~BreakFinder() { TextSegment BreakFinder::Next() { if (subBreak == -1) { - int prev = nextBreak; + const int prev = nextBreak; while (nextBreak < lineRange.end) { int charWidth = 1; if (encodingFamily == efUnicode) @@ -529,7 +529,7 @@ TextSegment BreakFinder::Next() { } // Splitting up a long run from prev to nextBreak in lots of approximately lengthEachSubdivision. // For very long runs add extra breaks after spaces or if no spaces before low punctuation. - int startSegment = subBreak; + const int startSegment = subBreak; if ((nextBreak - subBreak) <= lengthEachSubdivision) { subBreak = -1; return TextSegment(startSegment, nextBreak - startSegment); @@ -659,12 +659,12 @@ void PositionCache::MeasureWidths(Surface *surface, const ViewStyle &vstyle, uns // long comments with only a single comment. // Two way associative: try two probe positions. - unsigned int hashValue = PositionCacheEntry::Hash(styleNumber, s, len); + const unsigned int hashValue = PositionCacheEntry::Hash(styleNumber, s, len); probe = hashValue % pces.size(); if (pces[probe].Retrieve(styleNumber, s, len, positions)) { return; } - unsigned int probe2 = (hashValue * 37) % pces.size(); + const unsigned int probe2 = (hashValue * 37) % pces.size(); if (pces[probe2].Retrieve(styleNumber, s, len, positions)) { return; } @@ -678,7 +678,7 @@ void PositionCache::MeasureWidths(Surface *surface, const ViewStyle &vstyle, uns unsigned int startSegment = 0; XYPOSITION xStartSegment = 0; while (startSegment < len) { - unsigned int lenSegment = pdoc->SafeSegment(s + startSegment, len - startSegment, BreakFinder::lengthEachSubdivision); + const unsigned int lenSegment = pdoc->SafeSegment(s + startSegment, len - startSegment, BreakFinder::lengthEachSubdivision); FontAlias fontStyle = vstyle.styles[styleNumber].font; surface->MeasureWidths(fontStyle, s + startSegment, lenSegment, positions + startSegment); for (unsigned int inSeg = 0; inSeg < lenSegment; inSeg++) { |