Replace comparisons against "" with empty()

This commit is contained in:
Paul Licameli 2019-03-14 13:04:37 -04:00
parent 804b6c8bd8
commit 50074f2cfe
29 changed files with 67 additions and 67 deletions

View File

@ -1298,7 +1298,7 @@ bool AudacityApp::OnInit()
wxString home = wxGetHomeDir();
wxString envTempDir = wxGetenv(wxT("TMPDIR"));
if (envTempDir != wxT("")) {
if (!envTempDir.empty()) {
/* On Unix systems, the environment variable TMPDIR may point to
an unusual path when /tmp and /var/tmp are not desirable. */
defaultTempDir.Printf(wxT("%s/audacity-%s"), envTempDir, wxGetUserId());
@ -1313,7 +1313,7 @@ bool AudacityApp::OnInit()
#else
wxString pathVar = wxGetenv(wxT("DARKAUDACITY_PATH"));
#endif
if (pathVar != wxT(""))
if (!pathVar.empty())
AddMultiPathsToPathList(pathVar, audacityPathList);
AddUniquePathToPathList(::wxGetCwd(), audacityPathList);
@ -1770,7 +1770,7 @@ bool AudacityApp::InitTempDir()
// If that didn't work, try the default location
if (temp==wxT(""))
if (temp.empty())
SetToExtantDirectory( temp, tempDefaultLoc );
// Check temp directory ownership on *nix systems only
@ -1786,7 +1786,7 @@ bool AudacityApp::InitTempDir()
}
#endif
if (temp == wxT("")) {
if (temp.empty()) {
// Failed
if( !IsTempDirectoryNameOK( tempFromPrefs ) ) {
AudacityMessageBox(_("Audacity could not find a safe place to store temporary files.\nAudacity needs a place where automatic cleanup programs won't delete the temporary files.\nPlease enter an appropriate directory in the preferences dialog."));
@ -2095,7 +2095,7 @@ void AudacityApp::AddMultiPathsToPathList(const wxString &multiPathStringArg,
wxArrayString &pathList)
{
wxString multiPathString(multiPathStringArg);
while (multiPathString != wxT("")) {
while (!multiPathString.empty()) {
wxString onePath = multiPathString.BeforeFirst(wxPATH_SEP[0]);
multiPathString = multiPathString.AfterFirst(wxPATH_SEP[0]);
AddUniquePathToPathList(onePath, pathList);
@ -2110,7 +2110,7 @@ void AudacityApp::FindFilesInPathList(const wxString & pattern,
{
wxLogNull nolog;
if (pattern == wxT("")) {
if (pattern.empty()) {
return;
}

View File

@ -938,7 +938,7 @@ void InitAudioIO()
#endif
// Make sure device prefs are initialized
if (gPrefs->Read(wxT("AudioIO/RecordingDevice"), wxT("")) == wxT("")) {
if (gPrefs->Read(wxT("AudioIO/RecordingDevice"), wxT("")).empty()) {
int i = AudioIO::getRecordDevIndex();
const PaDeviceInfo *info = Pa_GetDeviceInfo(i);
if (info) {
@ -947,7 +947,7 @@ void InitAudioIO()
}
}
if (gPrefs->Read(wxT("AudioIO/PlaybackDevice"), wxT("")) == wxT("")) {
if (gPrefs->Read(wxT("AudioIO/PlaybackDevice"), wxT("")).empty()) {
int i = AudioIO::getPlayDevIndex();
const PaDeviceInfo *info = Pa_GetDeviceInfo(i);
if (info) {

View File

@ -936,7 +936,7 @@ bool MacroCommands::ReportAndSkip(
return false;
//TODO: Add a cancel button to these, and add the logic so that we can abort.
if( params != wxT("") )
if( !params.empty() )
{
AudacityMessageBox( wxString::Format(_("Apply %s with parameter(s)\n\n%s"),friendlyCommand, params),
_("Test Mode"));

View File

@ -1070,7 +1070,7 @@ void MacrosWindow::InsertCommandAt(int item)
}
Raise();
if(d.mSelectedCommand != wxT(""))
if(!d.mSelectedCommand.empty())
{
mMacroCommands.AddToMacro(d.mSelectedCommand,
d.mSelectedParameters,

View File

@ -263,7 +263,7 @@ void BenchmarkDialog::OnSave( wxCommandEvent & WXUNUSED(event))
wxFD_SAVE | wxRESIZE_BORDER,
this);
if (fName == wxT(""))
if (fName.empty())
return;
mText->SaveFile(fName);

View File

@ -589,7 +589,7 @@ DirManager::ProjectSetter::Impl::Impl(
, moving{ moving_ }
{
// Choose new paths
if (newProjPath == wxT(""))
if (newProjPath.empty())
newProjPath = ::wxGetCwd();
dirManager.projPath = newProjPath;
@ -815,7 +815,7 @@ wxLongLong DirManager::GetFreeDiskSpace()
wxString DirManager::GetDataFilesDir() const
{
return projFull != wxT("")? projFull: mytemp;
return !projFull.empty()? projFull: mytemp;
}
void DirManager::SetLocalTempDir(const wxString &path)
@ -1031,7 +1031,7 @@ void DirManager::BalanceInfoDel(const wxString &file)
dirMidPool.erase(midkey);
// DELETE the actual directory
wxString dir=(projFull != wxT("")? projFull: mytemp);
wxString dir=(!projFull.empty()? projFull: mytemp);
dir += wxFILE_SEP_PATH;
dir += file.Mid(0,3);
dir += wxFILE_SEP_PATH;
@ -1051,7 +1051,7 @@ void DirManager::BalanceInfoDel(const wxString &file)
if(--dirTopPool[topnum]<1){
// do *not* erase the hash entry from dirTopPool
// *do* DELETE the actual directory
dir=(projFull != wxT("")? projFull: mytemp);
dir=(!projFull.empty()? projFull: mytemp);
dir += wxFILE_SEP_PATH;
dir += file.Mid(0,3);
wxFileName::Rmdir(dir);
@ -1695,7 +1695,7 @@ int DirManager::ProjectFSCK(const bool bForceError, const bool bAutoRecoverMode)
}
wxArrayString filePathArray; // *all* files in the project directory/subdirectories
wxString dirPath = (projFull != wxT("") ? projFull : mytemp);
wxString dirPath = (!projFull.empty() ? projFull : mytemp);
RecursivelyEnumerateWithProgress(
dirPath,
filePathArray, // output: all files in project directory tree
@ -2151,7 +2151,7 @@ void DirManager::FindOrphanBlockFiles(
void DirManager::RemoveOrphanBlockfiles()
{
wxArrayString filePathArray; // *all* files in the project directory/subdirectories
wxString dirPath = (projFull != wxT("") ? projFull : mytemp);
wxString dirPath = (!projFull.empty() ? projFull : mytemp);
RecursivelyEnumerateWithProgress(
dirPath,
filePathArray, // output: all files in project directory tree

View File

@ -1053,7 +1053,7 @@ void FreqWindow::OnExport(wxCommandEvent & WXUNUSED(event))
_("Export Spectral Data As:"),
wxEmptyString, fName, wxT("txt"), wxT("*.txt"), wxFD_SAVE | wxRESIZE_BORDER, this);
if (fName == wxT(""))
if (fName.empty())
return;
wxTextFile f(fName);

View File

@ -630,7 +630,7 @@ void LabelDialog::OnImport(wxCommandEvent & WXUNUSED(event))
this); // Parent
// They gave us one...
if (fileName != wxT("")) {
if (!fileName.empty()) {
wxTextFile f;
// Get at the data
@ -678,7 +678,7 @@ void LabelDialog::OnExport(wxCommandEvent & WXUNUSED(event))
wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxRESIZE_BORDER,
this);
if (fName == wxT(""))
if (fName.empty())
return;
// Move existing files out of the way. Otherwise wxTextFile will

View File

@ -286,7 +286,7 @@ void LabelTrack::RestoreFlags( const Flags& flags )
wxFont LabelTrack::GetFont(const wxString &faceName, int size)
{
wxFontEncoding encoding;
if (faceName == wxT(""))
if (faceName.empty())
encoding = wxFONTENCODING_DEFAULT;
else
encoding = wxFONTENCODING_SYSTEM;

View File

@ -241,10 +241,10 @@ void GetLanguages(wxArrayString &langCodes, wxArrayString &langNames)
if (fullCode.length() < 2)
continue;
if (localLanguageName[code] != wxT("")) {
if (!localLanguageName[code].empty()) {
name = localLanguageName[code];
}
if (localLanguageName[fullCode] != wxT("")) {
if (!localLanguageName[fullCode].empty()) {
name = localLanguageName[fullCode];
}
@ -252,7 +252,7 @@ void GetLanguages(wxArrayString &langCodes, wxArrayString &langNames)
code = fullCode;
}
if (tempHash[code] != wxT(""))
if (!tempHash[code].empty())
continue;
if (TranslationExists(audacityPathList, code) || code==wxT("en")) {

View File

@ -220,7 +220,7 @@ void ModuleManager::Initialize(CommandHandler &cmdHandler)
// Code from LoadLadspa that might be useful in load modules.
pathVar = wxGetenv(wxT("AUDACITY_MODULES_PATH"));
if (pathVar != wxT(""))
if (!pathVar.empty())
wxGetApp().AddMultiPathsToPathList(pathVar, pathList);
for (i = 0; i < audacityPathList.size(); i++) {
@ -355,7 +355,7 @@ bool ModuleManager::DiscoverProviders()
// Code from LoadLadspa that might be useful in load modules.
wxString pathVar = wxString::FromUTF8(getenv("AUDACITY_MODULES_PATH"));
if (pathVar != wxT(""))
if (!pathVar.empty())
{
wxGetApp().AddMultiPathsToPathList(pathVar, pathList);
}

View File

@ -3898,7 +3898,7 @@ bool AudacityProject::DoSave (const bool fromSaveAs,
wxString project, projName, projPath;
auto cleanup = finally( [&] {
if (safetyFileName != wxT("")) {
if (!safetyFileName.empty()) {
if (wxFileExists(mFileName))
wxRemove(mFileName);
wxRename(safetyFileName, mFileName);
@ -4071,7 +4071,7 @@ bool AudacityProject::DoSave (const bool fromSaveAs,
// If we get here, saving the project was successful, so we can DELETE
// the .bak file (because it now does not fit our block files anymore
// anyway).
if (safetyFileName != wxT(""))
if (!safetyFileName.empty())
wxRemoveFile(safetyFileName),
// cancel the cleanup:
safetyFileName = wxT("");
@ -4495,7 +4495,7 @@ For an audio file that will open in other apps, use 'Export'.\n");
wxFD_SAVE | wxRESIZE_BORDER,
this);
if (fName == wxT(""))
if (fName.empty())
return false;
filename = fName;
@ -5395,7 +5395,7 @@ bool AudacityProject::IsProjectSaved() {
// Otherwise it becomes true only when a project is first saved successfully
// in DirManager::SetProject
wxString sProjectName = mDirManager->GetProjectName();
return (sProjectName != wxT(""));
return (!sProjectName.empty());
}
// This is done to empty out the tracks, but without creating a new project.

View File

@ -541,7 +541,7 @@ void ScreenFrame::OnDirChoose(wxCommandEvent & WXUNUSED(event))
current);
dlog.ShowModal();
if (dlog.GetPath() != wxT("")) {
if (!dlog.GetPath().empty()) {
wxFileName tmpDirPath;
tmpDirPath.AssignDir(dlog.GetPath());
wxString path = tmpDirPath.GetPath(wxPATH_GET_VOLUME|wxPATH_GET_SEPARATOR);

View File

@ -312,7 +312,7 @@ void TimerRecordDialog::OnAutoSavePathButton_Click(wxCommandEvent& WXUNUSED(even
wxFD_SAVE | wxRESIZE_BORDER,
this);
if (fName == wxT(""))
if (fName.empty())
return;
AudacityProject* pProject = GetActiveProject();

View File

@ -45,7 +45,7 @@ bool BatchEvalCommand::Apply(const CommandContext & context)
MacroCommandsCatalog catalog(&context.project);
wxString macroName = GetString(wxT("MacroName"));
if (macroName != wxT(""))
if (!macroName.empty())
{
MacroCommands batch;
batch.ReadMacro(macroName);

View File

@ -769,7 +769,7 @@ void CommandManager::AddItem(const wxChar *name,
wxString cookedParameter;
const auto &parameter = options.parameter;
if( parameter == "" )
if( parameter.empty() )
cookedParameter = name;
else
cookedParameter = parameter;

View File

@ -786,7 +786,7 @@ wxRect ScreenshotCommand::GetTrackRect( AudacityProject * pProj, TrackPanel * pa
}
wxString ScreenshotCommand::WindowFileName(AudacityProject * proj, wxTopLevelWindow *w){
if (w != proj && w->GetTitle() != wxT("")) {
if (w != proj && !w->GetTitle().empty()) {
mFileName = MakeFileName(mFilePath,
kCaptureWhatStrings[ mCaptureMode ].Translation() +
(wxT("-") + w->GetTitle() + wxT("-")));

View File

@ -505,7 +505,7 @@ void ContrastDialog::OnExport(wxCommandEvent & WXUNUSED(event))
wxFD_SAVE | wxRESIZE_BORDER,
this);
if (fName == wxT(""))
if (fName.empty())
return;
wxTextFile f(fName);

View File

@ -1342,7 +1342,7 @@ void EffectEqualization::LoadCurves(const wxString &fileName, bool append)
// MJS: I don't know what the above means, or if I have broken it.
wxFileName fn;
if(fileName == wxT("")) {
if(fileName.empty()) {
// Check if presets are up to date.
wxString eqCurvesCurrentVersion = wxString::Format(wxT("%d.%d"), EQCURVES_VERSION, EQCURVES_REVISION);
wxString eqCurvesInstalledVersion = wxT("");
@ -1568,7 +1568,7 @@ bool EffectEqualization::GetDefaultFileName(wxFileName &fileName)
void EffectEqualization::SaveCurves(const wxString &fileName)
{
wxFileName fn;
if( fileName == wxT(""))
if( fileName.empty() )
{
// Construct default curve filename
//
@ -3358,7 +3358,7 @@ void EditCurvesDialog::OnRename(wxCommandEvent & WXUNUSED(event))
}
}
}
if( name == wxT("") || name == wxT("unnamed") )
if( name.empty() || name == wxT("unnamed") )
bad = true;
}

View File

@ -204,7 +204,7 @@ bool ExportPlugin::IsExtension(const wxString & ext, int index)
wxString defext = GetExtension(i);
auto defexts = GetExtensions(i);
int indofext = defexts.Index(ext, false);
if (defext == wxT("") || (indofext != wxNOT_FOUND))
if (defext.empty() || (indofext != wxNOT_FOUND))
isext = true;
}
return isext;

View File

@ -391,12 +391,12 @@ void ExportMultiple::EnableControls()
bool ok = true;
if (mLabel->GetValue() && mFirst->GetValue() &&
mFirstFileName->GetValue() == wxT("") &&
mPrefix->GetValue() == wxT(""))
mFirstFileName->GetValue().empty() &&
mPrefix->GetValue().empty())
ok = false;
if (mByNumber->GetValue() &&
mPrefix->GetValue() == wxT(""))
mPrefix->GetValue().empty())
ok = false;
mExport->Enable(ok);
@ -458,7 +458,7 @@ void ExportMultiple::OnChoose(wxCommandEvent& WXUNUSED(event))
_("Choose a location to save the exported files"),
mDir->GetValue());
dlog.ShowModal();
if (dlog.GetPath() != wxT(""))
if (!dlog.GetPath().empty())
mDir->SetValue(dlog.GetPath());
}

View File

@ -258,7 +258,7 @@ void OnExportLabels(const CommandContext &context)
wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxRESIZE_BORDER,
&project);
if (fName == wxT(""))
if (fName.empty())
return;
// Move existing files out of the way. Otherwise wxTextFile will
@ -343,7 +343,7 @@ void OnExportMIDI(const CommandContext &context)
wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxRESIZE_BORDER,
&project);
if (fName == wxT(""))
if (fName.empty())
return;
if(!fName.Contains(wxT("."))) {
@ -445,7 +445,7 @@ void OnImportLabels(const CommandContext &context)
wxRESIZE_BORDER, // Flags
&project); // Parent
if (fileName != wxT("")) {
if (!fileName.empty()) {
wxTextFile f;
f.Open(fileName);
@ -487,7 +487,7 @@ void OnImportMIDI(const CommandContext &context)
wxRESIZE_BORDER, // Flags
&project); // Parent
if (fileName != wxT(""))
if (!fileName.empty())
DoImportMIDI(&project, fileName);
}
#endif
@ -507,7 +507,7 @@ void OnImportRaw(const CommandContext &context)
wxRESIZE_BORDER, // Flags
&project); // Parent
if (fileName == wxT(""))
if (fileName.empty())
return;
TrackHolders newTracks;

View File

@ -236,7 +236,7 @@ void DevicePrefs::OnHost(wxCommandEvent & e)
wxString recDevice;
recDevice = mRecordDevice;
if (this->mRecordSource != wxT(""))
if (!this->mRecordSource.empty())
recDevice += wxT(": ") + mRecordSource;
mRecord->Clear();

View File

@ -145,7 +145,7 @@ void DirectoriesPrefs::OnChooseTempDir(wxCommandEvent & e)
_("Choose a location to place the temporary directory"),
oldTempDir );
int retval = dlog.ShowModal();
if (retval != wxID_CANCEL && dlog.GetPath() != wxT("")) {
if (retval != wxID_CANCEL && !dlog.GetPath().empty()) {
wxFileName tmpDirPath;
tmpDirPath.AssignDir(dlog.GetPath());

View File

@ -240,7 +240,7 @@ void DeviceToolBar::UpdatePrefs()
devName = gPrefs->Read(wxT("/AudioIO/RecordingDevice"), wxT(""));
sourceName = gPrefs->Read(wxT("/AudioIO/RecordingSource"), wxT(""));
if (sourceName == wxT(""))
if (sourceName.empty())
desc = devName;
else
desc = devName + wxT(": ") + sourceName;
@ -270,7 +270,7 @@ void DeviceToolBar::UpdatePrefs()
devName = gPrefs->Read(wxT("/AudioIO/PlaybackDevice"), wxT(""));
sourceName = gPrefs->Read(wxT("/AudioIO/PlaybackSource"), wxT(""));
if (sourceName == wxT(""))
if (sourceName.empty())
desc = devName;
else
desc = devName + wxT(": ") + sourceName;
@ -304,7 +304,7 @@ void DeviceToolBar::UpdatePrefs()
if (newChannels > 0 && oldChannels != newChannels)
mInputChannels->SetSelection(newChannels - 1);
if (hostName != wxT("") && mHost->GetStringSelection() != hostName)
if (!hostName.empty() && mHost->GetStringSelection() != hostName)
mHost->SetStringSelection(hostName);
RegenerateTooltips();
@ -577,7 +577,7 @@ void DeviceToolBar::FillHostDevices()
for (i = 0; i < inMaps.size(); i++) {
if (foundHostIndex == inMaps[i].hostIndex) {
mInput->Append(MakeDeviceSourceString(&inMaps[i]));
if (host == wxT("")) {
if (host.empty()) {
host = inMaps[i].hostString;
gPrefs->Write(wxT("/AudioIO/Host"), host);
mHost->SetStringSelection(host);
@ -592,7 +592,7 @@ void DeviceToolBar::FillHostDevices()
for (i = 0; i < outMaps.size(); i++) {
if (foundHostIndex == outMaps[i].hostIndex) {
mOutput->Append(MakeDeviceSourceString(&outMaps[i]));
if (host == wxT("")) {
if (host.empty()) {
host = outMaps[i].hostString;
gPrefs->Write(wxT("/AudioIO/Host"), host);
gPrefs->Flush();

View File

@ -970,7 +970,7 @@ HitTestPreview SelectHandle::Preview
MaySetOnDemandTip(pTrack.get(), tip);
}
if (tip == "") {
if (tip.empty()) {
tip = _("Click and drag to select audio");
}
if (HasEscape() && mUseSnap) {

View File

@ -90,7 +90,7 @@ ErrorDialog::ErrorDialog(
long buttonMask;
// only add the help button if we have a URL
buttonMask = (helpPage == wxT("")) ? eOkButton : (eHelpButton | eOkButton);
buttonMask = (helpPage.empty()) ? eOkButton : (eHelpButton | eOkButton);
dhelpPage = helpPage;
dClose = Close;
dModal = modal;

View File

@ -658,27 +658,27 @@ void NumericConverter::ParseFormatString( const wxString & untranslatedFormat)
else
remainder.ToDouble(&mScalingFactor);
i = format.length()-1; // force break out of loop
if (delimStr != wxT(""))
if (!delimStr.empty())
handleDelim = true;
if (numStr != wxT(""))
if (!numStr.empty())
handleNum = true;
}
else if ((format[i] >= '0' && format[i] <='9') ||
format[i] == wxT('*') || format[i] == wxT('#')) {
numStr += format[i];
if (delimStr != wxT(""))
if (!delimStr.empty())
handleDelim = true;
}
else {
delimStr += format[i];
if (numStr != wxT(""))
if (!numStr.empty())
handleNum = true;
}
if (i == format.length() - 1) {
if (numStr != wxT(""))
if (!numStr.empty())
handleNum = true;
if (delimStr != wxT(""))
if (!delimStr.empty())
handleDelim = true;
}

View File

@ -715,7 +715,7 @@ wxString Ruler::LabelString(double d, bool major)
}
}
if (mUnits != wxT(""))
if (!mUnits.empty())
s = (s + mUnits);
return s;
@ -1393,7 +1393,7 @@ void Ruler::Draw(wxDC& dc, const TimeTrack* timetrack)
mDC->SetFont(*mMinorMinorFont);
for(i=0; i<mNumMinorMinor; i++) {
if (mMinorMinorLabels[i].text != wxT(""))
if (!mMinorMinorLabels[i].text.empty())
{
int pos = mMinorMinorLabels[i].pos;
@ -1552,7 +1552,7 @@ void Ruler::SetCustomMinorLabels(wxArrayString *label, size_t numLabel, int star
void Ruler::Label::Draw(wxDC&dc, bool twoTone, wxColour c) const
{
if (text != wxT("")) {
if (!text.empty()) {
bool altColor = twoTone && value < 0.0;
#ifdef EXPERIMENTAL_THEMING