diff --git a/src/common/arrstr.cpp b/src/common/arrstr.cpp index 5a995d86c1..ccc25f23ab 100644 --- a/src/common/arrstr.cpp +++ b/src/common/arrstr.cpp @@ -490,11 +490,11 @@ bool wxArrayString::operator==(const wxArrayString& a) const wxString wxJoin(const wxArrayString& arr, const wxChar sep, const wxChar escape) { + wxString str; + size_t count = arr.size(); if ( count == 0 ) - return wxEmptyString; - - wxString str; + return str; // pre-allocate memory using the estimation of the average length of the // strings in the given array: this is very imprecise, of course, but diff --git a/src/common/datetimefmt.cpp b/src/common/datetimefmt.cpp index 0d2bb3498b..8fbf1e0034 100644 --- a/src/common/datetimefmt.cpp +++ b/src/common/datetimefmt.cpp @@ -2247,18 +2247,20 @@ enum TimeSpanPart // %l milliseconds (000 - 999) wxString wxTimeSpan::Format(const wxString& format) const { + wxString str; + // we deal with only positive time spans here and just add the sign in // front for the negative ones if ( IsNegative() ) { - wxString str(Negate().Format(format)); - return "-" + str; + str = "-"; + str << Negate().Format(format); + return str; } - wxCHECK_MSG( !format.empty(), wxEmptyString, + wxCHECK_MSG( !format.empty(), str, wxT("NULL format in wxTimeSpan::Format") ); - wxString str; str.Alloc(format.length()); // Suppose we have wxTimeSpan ts(1 /* hour */, 2 /* min */, 3 /* sec */) diff --git a/src/common/fontcmn.cpp b/src/common/fontcmn.cpp index da8e05d239..ae9b82607f 100644 --- a/src/common/fontcmn.cpp +++ b/src/common/fontcmn.cpp @@ -318,9 +318,10 @@ void wxFontBase::DoSetNativeFontInfo(const wxNativeFontInfo& info) wxString wxFontBase::GetNativeFontInfoDesc() const { - wxCHECK_MSG( IsOk(), wxEmptyString, wxT("invalid font") ); - wxString fontDesc; + + wxCHECK_MSG(IsOk(), fontDesc, "invalid font"); + const wxNativeFontInfo *fontInfo = GetNativeFontInfo(); if ( fontInfo ) { @@ -337,9 +338,10 @@ wxString wxFontBase::GetNativeFontInfoDesc() const wxString wxFontBase::GetNativeFontInfoUserDesc() const { - wxCHECK_MSG( IsOk(), wxEmptyString, wxT("invalid font") ); - wxString fontDesc; + + wxCHECK_MSG(IsOk(), fontDesc, "invalid font"); + const wxNativeFontInfo *fontInfo = GetNativeFontInfo(); if ( fontInfo ) { diff --git a/src/common/intl.cpp b/src/common/intl.cpp index df4c840a84..98140e22a7 100644 --- a/src/common/intl.cpp +++ b/src/common/intl.cpp @@ -976,27 +976,31 @@ const wxLanguageInfo *wxLocale::GetLanguageInfo(int lang) /* static */ wxString wxLocale::GetLanguageName(int lang) { + wxString string; + if ( lang == wxLANGUAGE_DEFAULT || lang == wxLANGUAGE_UNKNOWN ) - return wxEmptyString; + return string; const wxLanguageInfo *info = GetLanguageInfo(lang); - if ( !info ) - return wxEmptyString; - else - return info->Description; + if (info) + string = info->Description; + + return string; } /* static */ wxString wxLocale::GetLanguageCanonicalName(int lang) { + wxString string; + if ( lang == wxLANGUAGE_DEFAULT || lang == wxLANGUAGE_UNKNOWN ) - return wxEmptyString; + return string; const wxLanguageInfo *info = GetLanguageInfo(lang); - if ( !info ) - return wxEmptyString; - else - return info->CanonicalName; + if (info) + string = info->CanonicalName; + + return string; } /* static */ diff --git a/src/common/platinfo.cpp b/src/common/platinfo.cpp index f9d9b93aef..8de37f6e07 100644 --- a/src/common/platinfo.cpp +++ b/src/common/platinfo.cpp @@ -259,12 +259,14 @@ wxString wxPlatformInfo::GetOperatingSystemIdName(wxOperatingSystemId os) wxString wxPlatformInfo::GetPortIdName(wxPortId port, bool usingUniversal) { + wxString ret; + const unsigned idx = wxGetIndexFromEnumValue(port); - wxCHECK_MSG( idx < WXSIZEOF(wxPortIdNames), wxEmptyString, + wxCHECK_MSG( idx < WXSIZEOF(wxPortIdNames), ret, wxT("invalid port id") ); - wxString ret = wxPortIdNames[idx]; + ret = wxPortIdNames[idx]; if ( usingUniversal ) ret += wxT("/wxUniversal"); @@ -274,12 +276,14 @@ wxString wxPlatformInfo::GetPortIdName(wxPortId port, bool usingUniversal) wxString wxPlatformInfo::GetPortIdShortName(wxPortId port, bool usingUniversal) { + wxString ret; + const unsigned idx = wxGetIndexFromEnumValue(port); - wxCHECK_MSG( idx < WXSIZEOF(wxPortIdNames), wxEmptyString, + wxCHECK_MSG( idx < WXSIZEOF(wxPortIdNames), ret, wxT("invalid port id") ); - wxString ret = wxPortIdNames[idx]; + ret = wxPortIdNames[idx]; ret = ret.Mid(2).Lower(); // remove 'wx' prefix if ( usingUniversal ) diff --git a/src/common/string.cpp b/src/common/string.cpp index feb6d8e501..f741eb536e 100644 --- a/src/common/string.cpp +++ b/src/common/string.cpp @@ -1160,11 +1160,11 @@ int wxString::CmpNoCase(const wxString& s) const wxString wxString::FromAscii(const char *ascii, size_t len) { - if (!ascii || len == 0) - return wxEmptyString; - wxString res; + if (!ascii || len == 0) + return res; + { wxStringInternalBuffer buf(res, len); wxStringCharType *dest = buf; diff --git a/src/common/variant.cpp b/src/common/variant.cpp index e01d1e84f7..e11e43dfe6 100644 --- a/src/common/variant.cpp +++ b/src/common/variant.cpp @@ -139,13 +139,10 @@ bool wxVariant::operator!= (const wxVariant& variant) const wxString wxVariant::MakeString() const { + wxString str; if (!IsNull()) - { - wxString str; - if (GetData()->Write(str)) - return str; - } - return wxEmptyString; + GetData()->Write(str); + return str; } void wxVariant::SetData(wxVariantData* data) diff --git a/src/common/xti.cpp b/src/common/xti.cpp index e7dc6d1ee0..9be5507fea 100644 --- a/src/common/xti.cpp +++ b/src/common/xti.cpp @@ -946,10 +946,11 @@ void wxGenericPropertyAccessor::GetProperty(const wxObject *object, wxAny& value wxString wxAnyGetAsString( const wxAny& data) { - if ( data.IsNull() || data.GetTypeInfo()==NULL ) - return wxEmptyString; - wxString s; + + if ( data.IsNull() || data.GetTypeInfo()==NULL ) + return s; + data.GetTypeInfo()->ConvertToString(data,s); return s; }