fixed two scalability problems that made BTextView perform rather slow

with large contents:
* when searching for tab characters in DrawLine(), we now limit the search 
  to the current line, too (not only the end of the style) - this avoids
  scanning to the end of large contents repeatedly
* there's no need to refresh from the edit location to the end of the
  content in _DoInsertText(), we only need to refresh the part that has
  changed

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29960 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Oliver Tappe 2009-04-06 09:00:52 +00:00
parent 457f9cf840
commit 2da74964c0

View File

@ -3905,7 +3905,7 @@ BTextView::_DoInsertText(const char *inText, int32 inLength, int32 inOffset,
const text_run_array *inRuns)
{
_CancelInputMethod();
if (TextLength() + inLength > MaxBytes())
return;
@ -3923,12 +3923,11 @@ BTextView::_DoInsertText(const char *inText, int32 inLength, int32 inOffset,
InsertText(inText, inLength, inOffset, inRuns);
// offset the caret/selection
//int32 saveStart = fSelStart;
fSelStart += inLength;
fSelEnd += inLength;
fSelStart += inLength;
fClickOffset = fSelEnd = fSelStart;
// recalc line breaks and draw the text
_Refresh(inOffset, textLength, true, false);
_Refresh(inOffset, inOffset + inLength, true, true);
}
@ -3997,7 +3996,7 @@ BTextView::_DrawLine(BView *view, const int32 &lineNum,
view->SetFont(font);
view->SetHighColor(*color);
tabChars = numBytes;
tabChars = min_c(numBytes, length);
do {
foundTab = fText->FindChar(B_TAB, offset, &tabChars);
if (foundTab) {
@ -4046,9 +4045,7 @@ BTextView::_DrawLine(BView *view, const int32 &lineNum,
}
int32 returnedBytes = tabChars;
const char *stringToDraw = fText->GetString(offset,
&returnedBytes);
const char *stringToDraw = fText->GetString(offset, &returnedBytes);
view->SetDrawingMode(textRenderingMode);
view->DrawString(stringToDraw, returnedBytes);
if (foundTab) {
@ -4064,7 +4061,7 @@ BTextView::_DrawLine(BView *view, const int32 &lineNum,
offset += tabChars;
length -= tabChars;
numBytes -= tabChars;
tabChars = numBytes;
tabChars = min_c(numBytes, length);
numTabs = 0;
} while (foundTab && tabChars > 0);
}