Skip to content

Commit

Permalink
Avoid unneeded use of wxLocale in wxDateTime::Format()
Browse files Browse the repository at this point in the history
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
  • Loading branch information
vslavik committed Jan 30, 2015
1 parent f81d6f6 commit 3c0b17d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/common/datetimefmt.cpp
Expand Up @@ -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()
Expand Down

0 comments on commit 3c0b17d

Please sign in to comment.