Replace pointless looping by 'if'

The for loop was only to test if *some* track was selected, and its body only needs to be executed once.
Note that an empty IteratorRange is false and one with something in it is true.
This commit is contained in:
James Crook 2018-10-11 12:04:43 +01:00
parent 15a3ea7763
commit e20a98588c
1 changed files with 2 additions and 4 deletions

View File

@ -344,8 +344,7 @@ void ContrastDialog::OnGetForeground(wxCommandEvent & /*event*/)
{
AudacityProject *p = GetActiveProject();
for ( auto t : p->GetTracks()->Selected< const WaveTrack >() ) {
(void)t;// Compiler food;
if( p->GetTracks()->Selected< const WaveTrack >() ) {
mForegroundStartT->SetValue(p->mViewInfo.selectedRegion.t0());
mForegroundEndT->SetValue(p->mViewInfo.selectedRegion.t1());
}
@ -360,8 +359,7 @@ void ContrastDialog::OnGetBackground(wxCommandEvent & /*event*/)
{
AudacityProject *p = GetActiveProject();
for ( auto t : p->GetTracks()->Selected< const WaveTrack >() ) {
(void)t;// Compiler food;
if( p->GetTracks()->Selected< const WaveTrack >() ) {
mBackgroundStartT->SetValue(p->mViewInfo.selectedRegion.t0());
mBackgroundEndT->SetValue(p->mViewInfo.selectedRegion.t1());
}