Avoid at least some unnecessary setlocale() calls
Instead of calling wxLanguageInfo::GetLocaleName(), which called setlocale() at least thrice (first to query the current locale, second to try to change it and third to restore the original locale) and then calling setlocale() again if it succeeded, use the new TrySetLocale() method which calls setlocale() just once and doesn't require calling it again in the caller. This makes the code slightly more efficient but, more importantly, shorter and more clear.
This commit is contained in:
@@ -75,6 +75,13 @@ struct WXDLLIMPEXP_BASE wxLanguageInfo
|
||||
// setlocale() on the current system or empty string if this locale is not
|
||||
// supported
|
||||
wxString GetLocaleName() const;
|
||||
|
||||
// Call setlocale() and return non-null value if it works for this language.
|
||||
//
|
||||
// This function is mostly for internal use, as changing locale involves
|
||||
// more than just calling setlocale() on some platforms, use wxLocale to
|
||||
// do everything that needs to be done instead of calling this method.
|
||||
const char* TrySetLocale() const;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
Reference in New Issue
Block a user