Avoid unneeded use of wxLocale in wxDateTime::Format()

On OS X, wxDateTime::Format() uses wxString::Replace() to
unconditionally replace locale-specific %c, %x and %X specifiers in the
format string if present. Doing so causes three wxLocale::GetInfo()
calls that are often not necessary.

Check for the presence of these  specifiers before calling GetInfo().

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@78423 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
2015-01-30 15:53:05 +00:00
parent f81d6f68c6
commit 3c0b17d4b5

View File

@@ -316,9 +316,12 @@ wxString wxDateTime::Format(const wxString& formatp, const TimeZone& tz) const
wxString format = formatp;
#ifdef __WXOSX__
format.Replace("%c",wxLocale::GetInfo(wxLOCALE_DATE_TIME_FMT));
format.Replace("%x",wxLocale::GetInfo(wxLOCALE_SHORT_DATE_FMT));
format.Replace("%X",wxLocale::GetInfo(wxLOCALE_TIME_FMT));
if ( format.Contains("%c") )
format.Replace("%c", wxLocale::GetInfo(wxLOCALE_DATE_TIME_FMT));
if ( format.Contains("%x") )
format.Replace("%x", wxLocale::GetInfo(wxLOCALE_SHORT_DATE_FMT));
if ( format.Contains("%X") )
format.Replace("%X", wxLocale::GetInfo(wxLOCALE_TIME_FMT));
#endif
// we have to use our own implementation if the date is out of range of
// strftime()