diff options
author | nyamatongwe <unknown> | 2010-09-25 18:02:59 +1000 |
---|---|---|
committer | nyamatongwe <unknown> | 2010-09-25 18:02:59 +1000 |
commit | 10cf4beef4d7293d6d382fe4b3216da48fa87fa1 (patch) | |
tree | 07d01bea7f3d55860a7b45d500a5901f4d5b63d4 /src/Editor.cxx | |
parent | 16b604e76efd53716623978c94069fd6194c7005 (diff) | |
download | scintilla-mirror-10cf4beef4d7293d6d382fe4b3216da48fa87fa1.tar.gz |
Optimization of line layout by minimizing calls in Editor::LayoutLine and avoiding
case force processing unless at least one style uses a case force option.
Diffstat (limited to 'src/Editor.cxx')
-rw-r--r-- | src/Editor.cxx | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/src/Editor.cxx b/src/Editor.cxx index bca458037..836f3919a 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -2022,8 +2022,6 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou if (ll->validity == LineLayout::llInvalid) { ll->widthLine = LineLayout::wrapWidthInfinite; ll->lines = 1; - int numCharsInLine = 0; - int numCharsBeforeEOL = 0; if (vstyle.edgeState == EDGE_BACKGROUND) { ll->edgeColumn = pdoc->FindColumn(line, theEdge); if (ll->edgeColumn >= posLineStart) { @@ -2034,24 +2032,30 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou } char styleByte = 0; - int styleMask = pdoc->stylingBitsMask; + const int styleMask = pdoc->stylingBitsMask; ll->styleBitsSet = 0; // Fill base line layout - for (int charInDoc = posLineStart; charInDoc < posLineEnd; charInDoc++) { - char chDoc = pdoc->CharAt(charInDoc); - styleByte = pdoc->StyleAt(charInDoc); + const int lineLength = posLineEnd - posLineStart; + pdoc->GetCharRange(ll->chars, posLineStart, lineLength); + pdoc->GetStyleRange(ll->styles, posLineStart, lineLength); + int numCharsBeforeEOL = lineLength; + while ((numCharsBeforeEOL > 0) && IsEOLChar(ll->chars[numCharsBeforeEOL-1])) { + numCharsBeforeEOL--; + } + const int numCharsInLine = (vstyle.viewEOL) ? lineLength : numCharsBeforeEOL; + for (int charInLine = 0; charInLine < numCharsInLine; charInLine++) { + styleByte = ll->styles[charInLine]; ll->styleBitsSet |= styleByte; - if (vstyle.viewEOL || (!IsEOLChar(chDoc))) { - ll->chars[numCharsInLine] = chDoc; - ll->styles[numCharsInLine] = static_cast<char>(styleByte & styleMask); - ll->indicators[numCharsInLine] = static_cast<char>(styleByte & ~styleMask); - if (vstyle.styles[ll->styles[numCharsInLine]].caseForce == Style::caseUpper) - ll->chars[numCharsInLine] = static_cast<char>(toupper(chDoc)); - else if (vstyle.styles[ll->styles[numCharsInLine]].caseForce == Style::caseLower) - ll->chars[numCharsInLine] = static_cast<char>(tolower(chDoc)); - numCharsInLine++; - if (!IsEOLChar(chDoc)) - numCharsBeforeEOL++; + ll->styles[numCharsInLine] = static_cast<char>(styleByte & styleMask); + ll->indicators[numCharsInLine] = static_cast<char>(styleByte & ~styleMask); + } + if (vstyle.someStylesForceCase) { + for (int charInLine = 0; charInLine<lineLength; charInLine++) { + char chDoc = ll->chars[charInLine]; + if (vstyle.styles[ll->styles[charInLine]].caseForce == Style::caseUpper) + ll->chars[charInLine] = static_cast<char>(toupper(chDoc)); + else if (vstyle.styles[ll->styles[charInLine]].caseForce == Style::caseLower) + ll->chars[charInLine] = static_cast<char>(tolower(chDoc)); } } ll->xHighlightGuide = 0; |