Use wxString() instead of "" for empty strings

This will allow this code to work even when implicit conversion from
"const char*" is disabled in wxString and is already marginally more
efficient even now.

See https://github.com/wxWidgets/wxWidgets/pull/782
This commit is contained in:
Jan Niklas Hasse
2018-04-11 16:21:11 +02:00
committed by Vadim Zeitlin
parent e905b94436
commit 8d02384792
13 changed files with 19 additions and 19 deletions

View File

@@ -59,7 +59,7 @@ public:
// And we also use wxBU_EXACTFIT to avoid being resized up to the
// standard button size as this doesn't make sense for bitmap buttons
// which are not standard anyhow and should fit their bitmap size.
return wxButton::Create(parent, winid, "",
return wxButton::Create(parent, winid, wxString(),
pos, size,
style | wxBU_NOTEXT | wxBU_EXACTFIT,
validator, name);

View File

@@ -5239,7 +5239,7 @@ public:
virtual void Remove(long from, long to) wxOVERRIDE
{
Replace(from, to, "");
Replace(from, to, wxString());
}
virtual void Replace(long from, long to, const wxString& text) wxOVERRIDE
{

View File

@@ -1617,7 +1617,7 @@ public:
static wxString FromUTF8(const char *utf8)
{
if ( !utf8 || !wxStringOperations::IsValidUtf8String(utf8) )
return "";
return wxString();
return FromImpl(wxStringImpl(utf8));
}
@@ -1627,7 +1627,7 @@ public:
return FromUTF8(utf8);
if ( !utf8 || !wxStringOperations::IsValidUtf8String(utf8, len) )
return "";
return wxString();
return FromImpl(wxStringImpl(utf8, len));
}

View File

@@ -1124,7 +1124,7 @@ void wxDocManager::OnFileNew(wxCommandEvent& WXUNUSED(event))
void wxDocManager::OnFileOpen(wxCommandEvent& WXUNUSED(event))
{
if ( !CreateDocument("") )
if ( !CreateDocument(wxString()) )
{
OnOpenFileFailure();
}

View File

@@ -2464,7 +2464,7 @@ void wxFileName::SplitPath(const wxString& fullpath,
wxString wxFileName::StripExtension(const wxString& fullpath)
{
wxFileName fn(fullpath);
fn.SetExt("");
fn.SetExt(wxString());
return fn.GetFullPath();
}

View File

@@ -190,7 +190,7 @@ wxSize wxFileDialogBase::GetExtraControlSize()
// create the extra control in an empty dialog just to find its size: this
// is not terribly efficient but we do need to know the size before
// creating the native dialog and this seems to be the only way
wxDialog dlg(NULL, wxID_ANY, "");
wxDialog dlg(NULL, wxID_ANY, wxString());
return (*m_extraControlCreator)(&dlg)->GetSize();
}

View File

@@ -895,7 +895,7 @@ bool wxTIFFHandler::DoCanRead( wxInputStream& stream )
wxString copyright;
const wxString desc = ver.BeforeFirst('\n', &copyright);
copyright.Replace("\n", "");
copyright.Replace("\n", wxString());
return wxVersionInfo("libtiff", major, minor, micro, desc, copyright);
}

View File

@@ -1456,7 +1456,7 @@ void wxTranslations::SetLoader(wxTranslationsLoader *loader)
void wxTranslations::SetLanguage(wxLanguage lang)
{
if ( lang == wxLANGUAGE_DEFAULT )
SetLanguage("");
SetLanguage(wxString());
else
SetLanguage(wxLocale::GetLanguageCanonicalName(lang));
}
@@ -1926,7 +1926,7 @@ wxArrayString wxFileTranslationsLoader::GetAvailableTranslations(const wxString&
continue;
wxString lang;
for ( bool ok = dir.GetFirst(&lang, "", wxDIR_DIRS);
for ( bool ok = dir.GetFirst(&lang, wxString(), wxDIR_DIRS);
ok;
ok = dir.GetNext(&lang) )
{

View File

@@ -177,7 +177,7 @@ wxString wxURI::GetPassword() const
size_t posColon = m_userinfo.find(':');
if ( posColon == wxString::npos )
return "";
return wxString();
return m_userinfo(posColon + 1, wxString::npos);
}
@@ -742,7 +742,7 @@ void wxURI::Resolve(const wxURI& base, int flags)
// if we have an empty path it means we were constructed from a "."
// string or something similar (e.g. "././././"), it should count
// as (empty) segment
our.push_back("");
our.push_back(wxString());
}
const wxArrayString::const_iterator end = our.end();
@@ -753,7 +753,7 @@ void wxURI::Resolve(const wxURI& base, int flags)
// as in ParsePath(), while normally we ignore the empty
// segments, we need to take account of them at the end
if ( i == end - 1 )
result.push_back("");
result.push_back(wxString());
continue;
}
@@ -764,7 +764,7 @@ void wxURI::Resolve(const wxURI& base, int flags)
result.pop_back();
if ( i == end - 1 )
result.push_back("");
result.push_back(wxString());
}
//else: just ignore, extra ".." don't accumulate
}
@@ -773,7 +773,7 @@ void wxURI::Resolve(const wxURI& base, int flags)
if ( result.empty() )
{
// ensure that the resulting path will always be absolute
result.push_back("");
result.push_back(wxString());
}
result.push_back(*i);

View File

@@ -77,7 +77,7 @@ bool wxInfoBarGeneric::Create(wxWindow *parent, wxWindowID winid)
// the icon is not shown unless it's assigned a valid bitmap
m_icon = new wxStaticBitmap(this, wxID_ANY, wxNullBitmap);
m_text = new wxStaticText(this, wxID_ANY, "");
m_text = new wxStaticText(this, wxID_ANY, wxString());
m_text->SetForegroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_INFOTEXT));
m_button = wxBitmapButton::NewCloseButton(this, wxID_ANY);

View File

@@ -77,7 +77,7 @@ public:
}
//else: Simply don't show any icon.
wxStaticText* const labelTitle = new wxStaticText(this, wxID_ANY, "");
wxStaticText* const labelTitle = new wxStaticText(this, wxID_ANY, wxString());
labelTitle->SetLabelText(title);
wxFont titleFont(titleFont_);

View File

@@ -110,7 +110,7 @@ bool wxNativeContainerWindow::Create(wxNativeContainerWindowHandle win)
{
wxCHECK( win, false );
if ( !wxTopLevelWindow::Create(NULL, wxID_ANY, "") )
if ( !wxTopLevelWindow::Create(NULL, wxID_ANY, wxString()) )
return false;
// we need to realize the window first before reparenting it

View File

@@ -2584,7 +2584,7 @@ void wxXmlResource::ReportError(const wxXmlNode *context, const wxString& messag
{
if ( !context )
{
DoReportError("", NULL, message);
DoReportError(wxString(), NULL, message);
return;
}