diff options
author | Neil <nyamatongwe@gmail.com> | 2014-05-12 10:55:05 +1000 |
---|---|---|
committer | Neil <nyamatongwe@gmail.com> | 2014-05-12 10:55:05 +1000 |
commit | 62b5d8dfe5d179b3543834e6f5f60576be1585da (patch) | |
tree | 5e52933053ae68bc3abaa1ea527869d7b4394831 | |
parent | b9416946b48ebebcdfac9b96fa8a6ecce62b62c3 (diff) | |
download | scintilla-mirror-62b5d8dfe5d179b3543834e6f5f60576be1585da.tar.gz |
Split variable into two as used for different reasons. Use unsigned to avoid
possibility of sign extension problems and to minimize type conversions.
-rw-r--r-- | src/Editor.cxx | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/Editor.cxx b/src/Editor.cxx index f1e019b07..24900dc77 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -2223,7 +2223,6 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou ll->edgeColumn = -1; } - char styleByte; const int styleMask = pdoc->stylingBitsMask; ll->styleBitsSet = 0; // Fill base line layout @@ -2233,12 +2232,12 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou int numCharsBeforeEOL = pdoc->LineEnd(line) - posLineStart; const int numCharsInLine = (vstyle.viewEOL) ? lineLength : numCharsBeforeEOL; for (int styleInLine = 0; styleInLine < numCharsInLine; styleInLine++) { - styleByte = ll->styles[styleInLine]; + const unsigned char styleByte = ll->styles[styleInLine]; ll->styleBitsSet |= styleByte; - ll->styles[styleInLine] = static_cast<char>(styleByte & styleMask); + ll->styles[styleInLine] = styleByte & styleMask; ll->indicators[styleInLine] = static_cast<char>(styleByte & ~styleMask); } - styleByte = static_cast<char>(((lineLength > 0) ? ll->styles[lineLength-1] : 0) & styleMask); + const unsigned char styleByteLast = ((lineLength > 0) ? ll->styles[lineLength-1] : 0) & styleMask; if (vstyle.someStylesForceCase) { for (int charInLine = 0; charInLine<lineLength; charInLine++) { char chDoc = ll->chars[charInLine]; @@ -2251,7 +2250,7 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou ll->xHighlightGuide = 0; // Extra element at the end of the line to hold end x position and act as ll->chars[numCharsInLine] = 0; // Also triggers processing in the loops as this is a control character - ll->styles[numCharsInLine] = styleByte; // For eolFilled + ll->styles[numCharsInLine] = styleByteLast; // For eolFilled ll->indicators[numCharsInLine] = 0; // Layout the line, determining the position of each character, |