[Summary] Adding option to avoid sorting the routs in Session::foreach method. Now ARDOUR_UI::every_second do not spend time for unnecessary sorting when calling update_disk_space().

[Reviewed] Paul Davis
[Required review] YPozdnyakov, GZharun
This commit is contained in:
Valeriy Kamyshniy
2015-04-02 21:51:23 +03:00
committed by Paul Davis
parent 5001a680fc
commit 21193c6fca
3 changed files with 19 additions and 16 deletions

View File

@@ -1420,7 +1420,7 @@ ARDOUR_UI::update_disk_space()
snprintf (buf, sizeof (buf), "%s", _("Disk: <span foreground=\"green\">24hrs+</span>"));
} else {
rec_enabled_streams = 0;
_session->foreach_route (this, &ARDOUR_UI::count_recenabled_streams);
_session->foreach_route (this, &ARDOUR_UI::count_recenabled_streams, false);
framecnt_t frames = opt_frames.get_value_or (0);

View File

@@ -247,9 +247,9 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop
void notify_remote_id_change ();
void sync_order_keys ();
template<class T> void foreach_route (T *obj, void (T::*func)(Route&));
template<class T> void foreach_route (T *obj, void (T::*func)(boost::shared_ptr<Route>));
template<class T, class A> void foreach_route (T *obj, void (T::*func)(Route&, A), A arg);
template<class T> void foreach_route (T *obj, void (T::*func)(Route&), bool sort = true);
template<class T> void foreach_route (T *obj, void (T::*func)(boost::shared_ptr<Route>), bool sort = true);
template<class T, class A> void foreach_route (T *obj, void (T::*func)(Route&, A), A arg, bool sort = true);
static char session_name_is_legal (const std::string&);
bool io_name_is_legal (const std::string&);

View File

@@ -30,27 +30,29 @@
namespace ARDOUR {
template<class T> void
Session::foreach_route (T *obj, void (T::*func)(Route&))
Session::foreach_route (T *obj, void (T::*func)(Route&), bool sort)
{
boost::shared_ptr<RouteList> r = routes.reader();
RouteList public_order (*r);
RoutePublicOrderSorter cmp;
public_order.sort (cmp);
if (sort) {
public_order.sort (RoutePublicOrderSorter());
}
for (RouteList::iterator i = public_order.begin(); i != public_order.end(); i++) {
(obj->*func) (**i);
}
}
template<class T> void
Session::foreach_route (T *obj, void (T::*func)(boost::shared_ptr<Route>))
Session::foreach_route (T *obj, void (T::*func)(boost::shared_ptr<Route>), bool sort)
{
boost::shared_ptr<RouteList> r = routes.reader();
RouteList public_order (*r);
RoutePublicOrderSorter cmp;
public_order.sort (cmp);
if (sort) {
public_order.sort (RoutePublicOrderSorter());
}
for (RouteList::iterator i = public_order.begin(); i != public_order.end(); i++) {
(obj->*func) (*i);
@@ -58,13 +60,14 @@ Session::foreach_route (T *obj, void (T::*func)(boost::shared_ptr<Route>))
}
template<class T, class A> void
Session::foreach_route (T *obj, void (T::*func)(Route&, A), A arg1)
Session::foreach_route (T *obj, void (T::*func)(Route&, A), A arg1, bool sort)
{
boost::shared_ptr<RouteList> r = routes.reader();
RouteList public_order (*r);
RoutePublicOrderSorter cmp;
public_order.sort (cmp);
if (sort) {
public_order.sort (RoutePublicOrderSorter());
}
for (RouteList::iterator i = public_order.begin(); i != public_order.end(); i++) {
(obj->*func) (**i, arg1);