Optimize wxTextCtrl::GetLastPosition()

It's better to call one API instead of four.
This commit is contained in:
Artur Wieczorek 2017-09-01 09:03:21 +02:00
parent 4fc8753285
commit c51dd81db6

View File

@ -1334,12 +1334,19 @@ wxTextPos wxTextCtrl::GetLastPosition() const
{
if ( IsMultiLine() )
{
int numLines = GetNumberOfLines();
long posStartLastLine = XYToPosition(0, numLines - 1);
long lenLastLine = GetLengthOfLineContainingPos(posStartLastLine);
return posStartLastLine + lenLastLine;
#if wxUSE_RICHEDIT
if ( IsRich() )
{
GETTEXTLENGTHEX gtl;
gtl.flags = GTL_NUMCHARS | GTL_PRECISE;
gtl.codepage = GetRichVersion() > 1 ? 1200 : CP_ACP;
return ::SendMessage(GetHwnd(), EM_GETTEXTLENGTHEX, (WPARAM)&gtl, 0);
}
else
#endif // wxUSE_RICHEDIT
{
return ::GetWindowTextLength(GetHwnd());
}
}
return wxTextEntry::GetLastPosition();