Permalink
Browse files

Avoid excessive string allocations in updateLineStartList. Fixes some…

… performance issues.
  • Loading branch information...
Shyotl committed Jun 4, 2016
1 parent 8ff1f46 commit 4f4a6d45880d13816fbbe9850fb64fa8d9b9f6b6
Showing with 11 additions and 2 deletions.
  1. +11 −2 indra/llui/lltexteditor.cpp
@@ -551,8 +551,17 @@ void LLTextEditor::updateLineStartList(S32 startpos)
}
}
else
{
const llwchar* str = mWText.c_str() + start_idx;
{
//Scratch buffer. Avoid needless realloc.
static LLWString buf;
if(start_idx)
{
buf.resize(end_idx - start_idx);
std::copy(mWText.begin() + start_idx, mWText.begin() + end_idx, buf.begin());
}
const LLWString& str = start_idx ? buf : mWText;
S32 drawn = mGLFont->maxDrawableChars(str, (F32)abs(mTextRect.getWidth()) - line_width,
end_idx - start_idx, mWordWrap ? LLFontGL::WORD_BOUNDARY_IF_POSSIBLE : LLFontGL::ANYWHERE, mAllowEmbeddedItems );
if( 0 == drawn && line_width == start_x)

0 comments on commit 4f4a6d4

Please sign in to comment.