From 247afab527ec1355b9caaa0eea76b981db92a782 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 18 Dec 2009 14:47:18 +0000 Subject: [PATCH] Only call GetTextMetrics() in wxDC::GetTextExtent() if necessary. A micro-optimization: avoid ::GetTextMetrics() call if we don't use its results (as is the case if neither descent nor external leading were requested). git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62926 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/dc.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/msw/dc.cpp b/src/msw/dc.cpp index 54b5e781fa..675447fe3a 100644 --- a/src/msw/dc.cpp +++ b/src/msw/dc.cpp @@ -1772,17 +1772,21 @@ void wxMSWDCImpl::DoGetTextExtent(const wxString& string, wxCoord *x, wxCoord *y } #endif // !defined(_WIN32_WCE) || (_WIN32_WCE >= 400) - TEXTMETRIC tm; - ::GetTextMetrics(GetHdc(), &tm); - if (x) *x = sizeRect.cx; if (y) *y = sizeRect.cy; - if (descent) - *descent = tm.tmDescent; - if (externalLeading) - *externalLeading = tm.tmExternalLeading; + + if ( descent || externalLeading ) + { + TEXTMETRIC tm; + ::GetTextMetrics(GetHdc(), &tm); + + if (descent) + *descent = tm.tmDescent; + if (externalLeading) + *externalLeading = tm.tmExternalLeading; + } if ( hfontOld ) { -- 2.45.2