From 8d02384792bf090e2f21d65f65b67faae3b90807 Mon Sep 17 00:00:00 2001 From: Jan Niklas Hasse Date: Wed, 11 Apr 2018 16:21:11 +0200 Subject: [PATCH] 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 --- include/wx/bmpbuttn.h | 2 +- include/wx/stc/stc.h | 2 +- include/wx/string.h | 4 ++-- src/common/docview.cpp | 2 +- src/common/filename.cpp | 2 +- src/common/fldlgcmn.cpp | 2 +- src/common/imagtiff.cpp | 2 +- src/common/translation.cpp | 4 ++-- src/common/uri.cpp | 10 +++++----- src/generic/infobar.cpp | 2 +- src/generic/richtooltipg.cpp | 2 +- src/gtk/nativewin.cpp | 2 +- src/xrc/xmlres.cpp | 2 +- 13 files changed, 19 insertions(+), 19 deletions(-) diff --git a/include/wx/bmpbuttn.h b/include/wx/bmpbuttn.h index 2aec670359..4bf85e0b53 100644 --- a/include/wx/bmpbuttn.h +++ b/include/wx/bmpbuttn.h @@ -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); diff --git a/include/wx/stc/stc.h b/include/wx/stc/stc.h index 43b4e97b6f..d14ad5511f 100644 --- a/include/wx/stc/stc.h +++ b/include/wx/stc/stc.h @@ -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 { diff --git a/include/wx/string.h b/include/wx/string.h index a4e682b8ff..031cff5a60 100644 --- a/include/wx/string.h +++ b/include/wx/string.h @@ -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)); } diff --git a/src/common/docview.cpp b/src/common/docview.cpp index 5be66f1190..54c4f6a5f7 100644 --- a/src/common/docview.cpp +++ b/src/common/docview.cpp @@ -1124,7 +1124,7 @@ void wxDocManager::OnFileNew(wxCommandEvent& WXUNUSED(event)) void wxDocManager::OnFileOpen(wxCommandEvent& WXUNUSED(event)) { - if ( !CreateDocument("") ) + if ( !CreateDocument(wxString()) ) { OnOpenFileFailure(); } diff --git a/src/common/filename.cpp b/src/common/filename.cpp index a733643d71..a1460b5d94 100644 --- a/src/common/filename.cpp +++ b/src/common/filename.cpp @@ -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(); } diff --git a/src/common/fldlgcmn.cpp b/src/common/fldlgcmn.cpp index a908d3fb44..69f28d5320 100644 --- a/src/common/fldlgcmn.cpp +++ b/src/common/fldlgcmn.cpp @@ -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(); } diff --git a/src/common/imagtiff.cpp b/src/common/imagtiff.cpp index ed8cb22fd4..081b2a58bd 100644 --- a/src/common/imagtiff.cpp +++ b/src/common/imagtiff.cpp @@ -895,7 +895,7 @@ bool wxTIFFHandler::DoCanRead( wxInputStream& stream ) wxString copyright; const wxString desc = ver.BeforeFirst('\n', ©right); - copyright.Replace("\n", ""); + copyright.Replace("\n", wxString()); return wxVersionInfo("libtiff", major, minor, micro, desc, copyright); } diff --git a/src/common/translation.cpp b/src/common/translation.cpp index 21dc0daf50..b092eaa9f9 100644 --- a/src/common/translation.cpp +++ b/src/common/translation.cpp @@ -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) ) { diff --git a/src/common/uri.cpp b/src/common/uri.cpp index 959f4ea2c9..e46b0e13d4 100644 --- a/src/common/uri.cpp +++ b/src/common/uri.cpp @@ -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); diff --git a/src/generic/infobar.cpp b/src/generic/infobar.cpp index 2ca258faf9..9d270e9735 100644 --- a/src/generic/infobar.cpp +++ b/src/generic/infobar.cpp @@ -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); diff --git a/src/generic/richtooltipg.cpp b/src/generic/richtooltipg.cpp index 5ebc1603ef..d9dd480d96 100644 --- a/src/generic/richtooltipg.cpp +++ b/src/generic/richtooltipg.cpp @@ -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_); diff --git a/src/gtk/nativewin.cpp b/src/gtk/nativewin.cpp index 03baa60d35..b3664b55b0 100644 --- a/src/gtk/nativewin.cpp +++ b/src/gtk/nativewin.cpp @@ -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 diff --git a/src/xrc/xmlres.cpp b/src/xrc/xmlres.cpp index 1963ba9d73..1ac4e51b51 100644 --- a/src/xrc/xmlres.cpp +++ b/src/xrc/xmlres.cpp @@ -2584,7 +2584,7 @@ void wxXmlResource::ReportError(const wxXmlNode *context, const wxString& messag { if ( !context ) { - DoReportError("", NULL, message); + DoReportError(wxString(), NULL, message); return; }