rippling - use a list and ::push_front() to avoid having to reverse

This commit is contained in:
Paul Davis 2023-04-12 10:38:27 -06:00
parent b4291cfb32
commit 36525a1ada
1 changed files with 4 additions and 7 deletions

View File

@ -32,7 +32,6 @@
#include <unistd.h>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <string>
@ -4940,7 +4939,7 @@ Editor::cut_copy_regions (CutCopyOp op, RegionSelection& rs)
Ripple (std::shared_ptr<Playlist> pl, timepos_t const & pos, timecnt_t const & len) : playlist (pl), position (pos), length (len) {}
};
std::vector<Ripple> ripple_list;
std::list<Ripple> ripple_list;
for (RegionSelection::iterator x = rs.begin(); x != rs.end(); ) {
@ -4991,7 +4990,7 @@ Editor::cut_copy_regions (CutCopyOp op, RegionSelection& rs)
case Delete:
pl->remove_region (r);
if (should_ripple()) {
ripple_list.push_back (Ripple (pl, r->position(), -r->length()));
ripple_list.push_front (Ripple (pl, r->position(), -r->length()));
}
break;
@ -5000,7 +4999,7 @@ Editor::cut_copy_regions (CutCopyOp op, RegionSelection& rs)
npl->add_region (_xx, timepos_t (first_position.distance (r->position())));
pl->remove_region (r);
if (should_ripple()) {
ripple_list.push_back (Ripple (pl, r->position(), -r->length()));
ripple_list.push_front (Ripple (pl, r->position(), -r->length()));
}
break;
@ -5012,7 +5011,7 @@ Editor::cut_copy_regions (CutCopyOp op, RegionSelection& rs)
case Clear:
pl->remove_region (r);
if (should_ripple()) {
ripple_list.push_back (Ripple (pl, r->position(), -r->length()));
ripple_list.push_front (Ripple (pl, r->position(), -r->length()));
}
break;
}
@ -5028,8 +5027,6 @@ Editor::cut_copy_regions (CutCopyOp op, RegionSelection& rs)
* timeline and then work towards zero.
*/
std::reverse (ripple_list.begin(), ripple_list.end());
for (auto const & ripple : ripple_list) {
do_ripple (ripple.playlist, ripple.position, ripple.length, nullptr, freezelist, false);
}