@@ -1063,14 +1063,16 @@ PortManager::update_input_ports (bool clear)
1063
1063
} else {
1064
1064
std::shared_ptr<AudioInputPorts const > aip = _audio_input_ports.reader ();
1065
1065
/* find new audio ports */
1066
- for (std::vector<std::string>::iterator p = audio_ports.begin (); p != audio_ports.end (); ++p) {
1067
- if (port_is_mine (*p) || !_backend->get_port_by_name (*p)) {
1068
- continue ;
1066
+ static_cast <void > (std::copy_if (
1067
+ audio_ports.cbegin (),
1068
+ audio_ports.cend (),
1069
+ new_audio.begin (),
1070
+ [&] (const std::string& p) {
1071
+ return !port_is_mine (p)
1072
+ && _backend->get_port_by_name (p)
1073
+ && aip->find (p) == aip->end ();
1069
1074
}
1070
- if (aip->find (*p) == aip->end ()) {
1071
- new_audio.push_back (*p);
1072
- }
1073
- }
1075
+ ));
1074
1076
1075
1077
/* find stale audio ports */
1076
1078
for (auto const & p : *aip) {
@@ -1081,19 +1083,20 @@ PortManager::update_input_ports (bool clear)
1081
1083
1082
1084
std::shared_ptr<MIDIInputPorts const > mip = _midi_input_ports.reader ();
1083
1085
/* find new MIDI ports */
1084
- for (std::vector<std::string>::iterator p = midi_ports.begin (); p != midi_ports.end (); ++p) {
1085
- if (port_is_mine (*p) || !_backend->get_port_by_name (*p)) {
1086
- continue ;
1087
- }
1086
+ static_cast <void > (std::copy_if (
1087
+ midi_ports.cbegin (),
1088
+ midi_ports.cend (),
1089
+ new_audio.begin (),
1090
+ [&, this ] (const std::string& p) {
1091
+ return !port_is_mine (p)
1092
+ && _backend->get_port_by_name (p)
1088
1093
#ifdef HAVE_ALSA
1089
- if ((*p).find (X_ (" Midi Through" )) != string::npos || (*p).find (X_ (" Midi-Through" )) != string::npos) {
1090
- continue ;
1091
- }
1094
+ && p.find (X_ (" Midi Through" )) == string::npos
1095
+ && p.find (X_ (" Midi-Through" )) == string::npos
1092
1096
#endif
1093
- if (mip->find (*p) == mip->end ()) {
1094
- new_midi.push_back (*p);
1097
+ && mip->find (p) == mip->end ();
1095
1098
}
1096
- }
1099
+ ));
1097
1100
1098
1101
/* find stale audio ports */
1099
1102
for (auto const & p : *mip) {
@@ -1585,15 +1588,16 @@ PortManager::get_configurable_midi_ports (vector<string>& copy, bool for_input)
1585
1588
1586
1589
std::vector<string> ports;
1587
1590
AudioEngine::instance ()->get_ports (string (), DataType::MIDI, flags, ports);
1588
- for (vector<string>::iterator p = ports.begin (); p != ports.end (); ++p) {
1589
- if (port_is_mine (*p) && !port_is_virtual_piano (*p)) {
1590
- continue ;
1591
- }
1592
- if ((*p).find (X_ (" Midi Through" )) != string::npos || (*p).find (X_ (" Midi-Through" )) != string::npos) {
1593
- continue ;
1594
- }
1595
- copy.push_back (*p);
1596
- }
1591
+ static_cast <void > (std::copy_if (
1592
+ ports.cbegin (),
1593
+ ports.cend (),
1594
+ copy.end (),
1595
+ [this ] (const string& p) {
1596
+ return !(port_is_mine (p) && !port_is_virtual_piano (p))
1597
+ && p.find (X_ (" Midi Through" )) == string::npos
1598
+ && p.find (X_ (" Midi-Through" )) == string::npos;
1599
+ }
1600
+ ));
1597
1601
}
1598
1602
1599
1603
void
0 commit comments