Cleanup: tidy Playlist::move_later().
authorCarl Hetherington <cth@carlh.net>
Tue, 8 Aug 2023 21:53:52 +0000 (23:53 +0200)
committerCarl Hetherington <cth@carlh.net>
Wed, 9 Aug 2023 08:18:46 +0000 (10:18 +0200)
src/lib/playlist.cc

index 80037b5755fcbfc0057a1bbd30392b9d37312d68..2f261d8a0ddb7d4c496a4065017ad8d4e9d0bc56 100644 (file)
@@ -629,24 +629,18 @@ void
 Playlist::move_later (shared_ptr<const Film> film, shared_ptr<Content> 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));
 }