From b4489de4679a41c96fe0dd5449a8721cdb2294b2 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 8 Aug 2023 23:53:52 +0200 Subject: [PATCH] Cleanup: tidy Playlist::move_later(). --- src/lib/playlist.cc | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/lib/playlist.cc b/src/lib/playlist.cc index 80037b575..2f261d8a0 100644 --- a/src/lib/playlist.cc +++ b/src/lib/playlist.cc @@ -629,24 +629,18 @@ void Playlist::move_later (shared_ptr film, shared_ptr c) { auto cont = content (); - auto i = cont.begin(); - while (i != cont.end() && *i != c) { - ++i; - } - DCPOMATIC_ASSERT (i != cont.end()); - - ContentList::iterator next = i; - ++next; + auto iter = std::find(cont.begin(), cont.end(), c); + DCPOMATIC_ASSERT(iter != cont.end()); + ContentList::iterator next = std::next(iter); if (next == cont.end()) { + /* This content is already at the end */ return; } - auto next_c = *next; - - next_c->set_position (film, c->position()); - c->set_position (film, c->position() + next_c->length_after_trim(film)); + (*next)->set_position(film, c->position()); + c->set_position(film, c->position() + (*next)->length_after_trim(film)); } -- 2.30.2