Prevent copy-construction of sources to be destroyed list

destroy_sources () is only called from Session::remove_last_capture ().
The list of sources to be destroyed is the local scope of that method
and will hold a reference to the object.
copy-construct the list and removing elements one by one from the
copy is only unnecessary overhead.
This commit is contained in:
Robin Gareus 2019-12-25 17:57:10 +01:00
parent c9c8cd2777
commit df17e3f041
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
2 changed files with 4 additions and 6 deletions

View File

@ -805,7 +805,7 @@ public:
int cleanup_sources (CleanupReport&);
int cleanup_trash_sources (CleanupReport&);
int destroy_sources (std::list<boost::shared_ptr<Source> >);
int destroy_sources (std::list<boost::shared_ptr<Source> > const&);
int remove_last_capture ();
void get_last_capture_sources (std::list<boost::shared_ptr<Source> >&);

View File

@ -4242,11 +4242,11 @@ Session::find_whole_file_parent (boost::shared_ptr<Region const> child) const
}
int
Session::destroy_sources (list<boost::shared_ptr<Source> > srcs)
Session::destroy_sources (list<boost::shared_ptr<Source> > const& srcs)
{
set<boost::shared_ptr<Region> > relevant_regions;
for (list<boost::shared_ptr<Source> >::iterator s = srcs.begin(); s != srcs.end(); ++s) {
for (list<boost::shared_ptr<Source> >::const_iterator s = srcs.begin(); s != srcs.end(); ++s) {
RegionFactory::get_regions_using_source (*s, relevant_regions);
}
@ -4267,7 +4267,7 @@ Session::destroy_sources (list<boost::shared_ptr<Source> > srcs)
r = tmp;
}
for (list<boost::shared_ptr<Source> >::iterator s = srcs.begin(); s != srcs.end(); ) {
for (list<boost::shared_ptr<Source> >::const_iterator s = srcs.begin(); s != srcs.end(); ++s) {
{
Glib::Threads::Mutex::Lock ls (source_lock);
@ -4278,8 +4278,6 @@ Session::destroy_sources (list<boost::shared_ptr<Source> > srcs)
(*s)->mark_for_remove ();
(*s)->drop_references ();
SourceRemoved(*s);
s = srcs.erase (s);
}
return 0;