From 3c0b17d4b5cbb6c1ac8282f6a1489b6260e09bf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Fri, 30 Jan 2015 15:53:05 +0000 Subject: [PATCH] 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 --- src/common/datetimefmt.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/common/datetimefmt.cpp b/src/common/datetimefmt.cpp index 9a75b64cc8..01402c8529 100644 --- a/src/common/datetimefmt.cpp +++ b/src/common/datetimefmt.cpp @@ -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()