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