Don't assume compiler can avoid copy to const ref.
[ardour.git] / libs / ardour / port_set.cc
index 7e9f0656c598a760886c541c5f3681ec18d10562..3489ae4e449a9fe43e527828b72b4a4ae7a57509 100644 (file)
 
 #include <string>
 
-#include "ardour/port_set.h"
-#include "ardour/midi_port.h"
 #include "ardour/audio_port.h"
+#include "ardour/midi_port.h"
+#include "ardour/port.h"
+#include "ardour/port_set.h"
 
 using std::string;
 
@@ -55,7 +56,7 @@ static bool sort_ports_by_name (boost::shared_ptr<Port> a, boost::shared_ptr<Por
 
        // if some of the names don't have a number as posfix, compare as strings
 
-       if (last_digit_position_a == aname.size() or last_digit_position_b == bname.size()) {
+       if (last_digit_position_a == aname.size() || last_digit_position_b == bname.size()) {
                return aname < bname;
        }
 
@@ -144,9 +145,11 @@ PortSet::port(DataType type, size_t n) const
                return port(n);
        } else {
                const PortVec& v = _ports[type];
-               assert(n < v.size());
-               return v[n];
+               if (n < v.size()) {
+                       return v[n];
+               }
        }
+       return boost::shared_ptr<Port>();
 }
 
 boost::shared_ptr<AudioPort>