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
This commit is contained in:
Vadim Zeitlin 2009-12-18 14:47:18 +00:00
parent ec38225e66
commit 247afab527

View File

@ -1772,17 +1772,21 @@ void wxMSWDCImpl::DoGetTextExtent(const wxString& string, wxCoord *x, wxCoord *y
} }
#endif // !defined(_WIN32_WCE) || (_WIN32_WCE >= 400) #endif // !defined(_WIN32_WCE) || (_WIN32_WCE >= 400)
TEXTMETRIC tm;
::GetTextMetrics(GetHdc(), &tm);
if (x) if (x)
*x = sizeRect.cx; *x = sizeRect.cx;
if (y) if (y)
*y = sizeRect.cy; *y = sizeRect.cy;
if (descent)
*descent = tm.tmDescent; if ( descent || externalLeading )
if (externalLeading) {
*externalLeading = tm.tmExternalLeading; TEXTMETRIC tm;
::GetTextMetrics(GetHdc(), &tm);
if (descent)
*descent = tm.tmDescent;
if (externalLeading)
*externalLeading = tm.tmExternalLeading;
}
if ( hfontOld ) if ( hfontOld )
{ {