[Libreoffice-commits] core.git: vcl/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Thu Jan 31 08:53:10 UTC 2019
vcl/source/control/edit.cxx | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
New commits:
commit 07ec9edc26f675646f04721acb3f1f0334a34530
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Wed Jan 30 17:23:20 2019 +0000
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Thu Jan 31 09:52:39 2019 +0100
Related: tdf#122780 skip GetTextWidth() when we don't need the result
Change-Id: I1919d3da162e05ea6fec6269a53344b0625338e9
Reviewed-on: https://gerrit.libreoffice.org/67174
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/vcl/source/control/edit.cxx b/vcl/source/control/edit.cxx
index f15daa864ede..bd5c6c8c55fc 100644
--- a/vcl/source/control/edit.cxx
+++ b/vcl/source/control/edit.cxx
@@ -1131,14 +1131,19 @@ void Edit::ImplShowCursor( bool bOnlyIfVisible )
void Edit::ImplAlign()
{
+ if (mnAlign == EDIT_ALIGN_LEFT && !mnXOffset)
+ {
+ // short circuit common case and avoid slow GetTextWidth() calc
+ return;
+ }
+
long nTextWidth = GetTextWidth( ImplGetText() );
long nOutWidth = GetOutputSizePixel().Width();
if ( mnAlign == EDIT_ALIGN_LEFT )
{
- if( mnXOffset && ( nTextWidth < nOutWidth ) )
+ if (nTextWidth < nOutWidth)
mnXOffset = 0;
-
}
else if ( mnAlign == EDIT_ALIGN_RIGHT )
{
@@ -1161,8 +1166,8 @@ void Edit::ImplAlign()
}
else if( mnAlign == EDIT_ALIGN_CENTER )
{
- // would be nicer with check while scrolling but then it's not centred in scrolled state
- mnXOffset = (nOutWidth - nTextWidth) / 2;
+ // would be nicer with check while scrolling but then it's not centred in scrolled state
+ mnXOffset = (nOutWidth - nTextWidth) / 2;
}
}
More information about the Libreoffice-commits
mailing list