From 6fafab0ea36ba8320e34be700a4dbf2c99aa3ea1 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 20 Jun 2012 17:54:49 +0000 Subject: [PATCH] No real changes, just simplify wxGDIPlusContext::GetTextExtent() a bit. Don't call Font::GetSize() and FontFamily::GetEmHeight() thrice, just do it once and store the results. This makes the code both simpler and shorter and marginally more efficient. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@71822 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/graphics.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/msw/graphics.cpp b/src/msw/graphics.cpp index 112e2d43f9..78f1e4aa0c 100644 --- a/src/msw/graphics.cpp +++ b/src/msw/graphics.cpp @@ -1773,12 +1773,11 @@ void wxGDIPlusContext::GetTextExtent( const wxString &str, wxDouble *width, wxDo // Notice that we must use the real font style or the results would be // incorrect for italic/bold fonts. const INT style = f->GetStyle(); - REAL rDescent = ffamily.GetCellDescent(style) * - f->GetSize() / ffamily.GetEmHeight(style); - REAL rAscent = ffamily.GetCellAscent(style) * - f->GetSize() / ffamily.GetEmHeight(style); - REAL rHeight = ffamily.GetLineSpacing(style) * - f->GetSize() / ffamily.GetEmHeight(style); + const REAL size = f->GetSize(); + const REAL emHeight = ffamily.GetEmHeight(style); + REAL rDescent = ffamily.GetCellDescent(style) * size / emHeight; + REAL rAscent = ffamily.GetCellAscent(style) * size / emHeight; + REAL rHeight = ffamily.GetLineSpacing(style) * size / emHeight; if ( height ) *height = rHeight * factorY; -- 2.47.2