Skip to content

Commit ce3e4f1

Browse files
committed
Optimize SelectedChannelsParameter::setChannelCount logic
1 parent eeaaa4f commit ce3e4f1

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

Source/Processors/Parameter/Parameter.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -859,13 +859,10 @@ void SelectedChannelsParameter::setChannelCount (int newCount)
859859
}
860860
else if (channelCount == 0 && currentValue.getArray()->size() == 0) // If the current count is 0, set the selected channels to the first maxSelectableChannels channels
861861
{
862-
for (int i = 0; i < maxSelectableChannels; i++)
863-
{
864-
if (i < newCount)
865-
{
866-
values.add (i);
867-
}
868-
}
862+
const int limit = jmin (maxSelectableChannels, newCount);
863+
values.ensureStorageAllocated (limit);
864+
for (int i = 0; i < limit; ++i)
865+
values.add (i);
869866

870867
currentValue = values;
871868
}

0 commit comments

Comments
 (0)