Remove returns of wxEmptyString

This commit is contained in:
Paul Cornett
2017-02-18 11:26:40 -08:00
parent 32535f5bf6
commit 6169ced23f
8 changed files with 47 additions and 37 deletions

View File

@@ -490,11 +490,11 @@ bool wxArrayString::operator==(const wxArrayString& a) const
wxString wxJoin(const wxArrayString& arr, const wxChar sep, const wxChar escape) wxString wxJoin(const wxArrayString& arr, const wxChar sep, const wxChar escape)
{ {
wxString str;
size_t count = arr.size(); size_t count = arr.size();
if ( count == 0 ) if ( count == 0 )
return wxEmptyString; return str;
wxString str;
// pre-allocate memory using the estimation of the average length of the // pre-allocate memory using the estimation of the average length of the
// strings in the given array: this is very imprecise, of course, but // strings in the given array: this is very imprecise, of course, but

View File

@@ -2247,18 +2247,20 @@ enum TimeSpanPart
// %l milliseconds (000 - 999) // %l milliseconds (000 - 999)
wxString wxTimeSpan::Format(const wxString& format) const wxString wxTimeSpan::Format(const wxString& format) const
{ {
wxString str;
// we deal with only positive time spans here and just add the sign in // we deal with only positive time spans here and just add the sign in
// front for the negative ones // front for the negative ones
if ( IsNegative() ) if ( IsNegative() )
{ {
wxString str(Negate().Format(format)); str = "-";
return "-" + str; str << Negate().Format(format);
return str;
} }
wxCHECK_MSG( !format.empty(), wxEmptyString, wxCHECK_MSG( !format.empty(), str,
wxT("NULL format in wxTimeSpan::Format") ); wxT("NULL format in wxTimeSpan::Format") );
wxString str;
str.Alloc(format.length()); str.Alloc(format.length());
// Suppose we have wxTimeSpan ts(1 /* hour */, 2 /* min */, 3 /* sec */) // Suppose we have wxTimeSpan ts(1 /* hour */, 2 /* min */, 3 /* sec */)

View File

@@ -318,9 +318,10 @@ void wxFontBase::DoSetNativeFontInfo(const wxNativeFontInfo& info)
wxString wxFontBase::GetNativeFontInfoDesc() const wxString wxFontBase::GetNativeFontInfoDesc() const
{ {
wxCHECK_MSG( IsOk(), wxEmptyString, wxT("invalid font") );
wxString fontDesc; wxString fontDesc;
wxCHECK_MSG(IsOk(), fontDesc, "invalid font");
const wxNativeFontInfo *fontInfo = GetNativeFontInfo(); const wxNativeFontInfo *fontInfo = GetNativeFontInfo();
if ( fontInfo ) if ( fontInfo )
{ {
@@ -337,9 +338,10 @@ wxString wxFontBase::GetNativeFontInfoDesc() const
wxString wxFontBase::GetNativeFontInfoUserDesc() const wxString wxFontBase::GetNativeFontInfoUserDesc() const
{ {
wxCHECK_MSG( IsOk(), wxEmptyString, wxT("invalid font") );
wxString fontDesc; wxString fontDesc;
wxCHECK_MSG(IsOk(), fontDesc, "invalid font");
const wxNativeFontInfo *fontInfo = GetNativeFontInfo(); const wxNativeFontInfo *fontInfo = GetNativeFontInfo();
if ( fontInfo ) if ( fontInfo )
{ {

View File

@@ -976,27 +976,31 @@ const wxLanguageInfo *wxLocale::GetLanguageInfo(int lang)
/* static */ /* static */
wxString wxLocale::GetLanguageName(int lang) wxString wxLocale::GetLanguageName(int lang)
{ {
wxString string;
if ( lang == wxLANGUAGE_DEFAULT || lang == wxLANGUAGE_UNKNOWN ) if ( lang == wxLANGUAGE_DEFAULT || lang == wxLANGUAGE_UNKNOWN )
return wxEmptyString; return string;
const wxLanguageInfo *info = GetLanguageInfo(lang); const wxLanguageInfo *info = GetLanguageInfo(lang);
if ( !info ) if (info)
return wxEmptyString; string = info->Description;
else
return info->Description; return string;
} }
/* static */ /* static */
wxString wxLocale::GetLanguageCanonicalName(int lang) wxString wxLocale::GetLanguageCanonicalName(int lang)
{ {
wxString string;
if ( lang == wxLANGUAGE_DEFAULT || lang == wxLANGUAGE_UNKNOWN ) if ( lang == wxLANGUAGE_DEFAULT || lang == wxLANGUAGE_UNKNOWN )
return wxEmptyString; return string;
const wxLanguageInfo *info = GetLanguageInfo(lang); const wxLanguageInfo *info = GetLanguageInfo(lang);
if ( !info ) if (info)
return wxEmptyString; string = info->CanonicalName;
else
return info->CanonicalName; return string;
} }
/* static */ /* static */

View File

@@ -259,12 +259,14 @@ wxString wxPlatformInfo::GetOperatingSystemIdName(wxOperatingSystemId os)
wxString wxPlatformInfo::GetPortIdName(wxPortId port, bool usingUniversal) wxString wxPlatformInfo::GetPortIdName(wxPortId port, bool usingUniversal)
{ {
wxString ret;
const unsigned idx = wxGetIndexFromEnumValue(port); const unsigned idx = wxGetIndexFromEnumValue(port);
wxCHECK_MSG( idx < WXSIZEOF(wxPortIdNames), wxEmptyString, wxCHECK_MSG( idx < WXSIZEOF(wxPortIdNames), ret,
wxT("invalid port id") ); wxT("invalid port id") );
wxString ret = wxPortIdNames[idx]; ret = wxPortIdNames[idx];
if ( usingUniversal ) if ( usingUniversal )
ret += wxT("/wxUniversal"); ret += wxT("/wxUniversal");
@@ -274,12 +276,14 @@ wxString wxPlatformInfo::GetPortIdName(wxPortId port, bool usingUniversal)
wxString wxPlatformInfo::GetPortIdShortName(wxPortId port, bool usingUniversal) wxString wxPlatformInfo::GetPortIdShortName(wxPortId port, bool usingUniversal)
{ {
wxString ret;
const unsigned idx = wxGetIndexFromEnumValue(port); const unsigned idx = wxGetIndexFromEnumValue(port);
wxCHECK_MSG( idx < WXSIZEOF(wxPortIdNames), wxEmptyString, wxCHECK_MSG( idx < WXSIZEOF(wxPortIdNames), ret,
wxT("invalid port id") ); wxT("invalid port id") );
wxString ret = wxPortIdNames[idx]; ret = wxPortIdNames[idx];
ret = ret.Mid(2).Lower(); // remove 'wx' prefix ret = ret.Mid(2).Lower(); // remove 'wx' prefix
if ( usingUniversal ) if ( usingUniversal )

View File

@@ -1160,11 +1160,11 @@ int wxString::CmpNoCase(const wxString& s) const
wxString wxString::FromAscii(const char *ascii, size_t len) wxString wxString::FromAscii(const char *ascii, size_t len)
{ {
if (!ascii || len == 0)
return wxEmptyString;
wxString res; wxString res;
if (!ascii || len == 0)
return res;
{ {
wxStringInternalBuffer buf(res, len); wxStringInternalBuffer buf(res, len);
wxStringCharType *dest = buf; wxStringCharType *dest = buf;

View File

@@ -139,13 +139,10 @@ bool wxVariant::operator!= (const wxVariant& variant) const
wxString wxVariant::MakeString() const wxString wxVariant::MakeString() const
{ {
if (!IsNull())
{
wxString str; wxString str;
if (GetData()->Write(str)) if (!IsNull())
GetData()->Write(str);
return str; return str;
}
return wxEmptyString;
} }
void wxVariant::SetData(wxVariantData* data) void wxVariant::SetData(wxVariantData* data)

View File

@@ -946,10 +946,11 @@ void wxGenericPropertyAccessor::GetProperty(const wxObject *object, wxAny& value
wxString wxAnyGetAsString( const wxAny& data) wxString wxAnyGetAsString( const wxAny& data)
{ {
if ( data.IsNull() || data.GetTypeInfo()==NULL )
return wxEmptyString;
wxString s; wxString s;
if ( data.IsNull() || data.GetTypeInfo()==NULL )
return s;
data.GetTypeInfo()->ConvertToString(data,s); data.GetTypeInfo()->ConvertToString(data,s);
return s; return s;
} }