From afed87b4f64f8cb4d99a0cad0eda664a604a10f7 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sat, 16 Dec 2023 22:50:25 +0100 Subject: [PATCH 1/1] Use std::vector and emplace_back(), lengthen variable name. --- src/lib/film.cc | 18 ++++++++++-------- src/lib/film.h | 2 +- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/lib/film.cc b/src/lib/film.cc index d747efb0e..d94ef0af3 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -1804,15 +1804,16 @@ Film::audio_analysis_finished () /* XXX */ } -list + +vector Film::reels () const { - list p; + vector periods; auto const len = length(); switch (reel_type ()) { case ReelType::SINGLE: - p.push_back (DCPTimePeriod (DCPTime (), len)); + periods.emplace_back(DCPTime(), len); break; case ReelType::BY_VIDEO_CONTENT: { @@ -1837,7 +1838,7 @@ Film::reels () const for (auto t: split_points) { if (last && (t - *last) >= DCPTime::from_seconds(1)) { /* Period from *last to t is long enough; use it and start a new one */ - p.push_back (DCPTimePeriod(*last, t)); + periods.emplace_back(*last, t); last = t; } else if (!last) { /* That was the first time, so start a new period */ @@ -1845,8 +1846,8 @@ Film::reels () const } } - if (!p.empty()) { - p.back().to = split_points.back(); + if (!periods.empty()) { + periods.back().to = split_points.back(); } break; } @@ -1859,16 +1860,17 @@ Film::reels () const Frame const reel_in_frames = max(_reel_length / ((j2k_bandwidth() / video_frame_rate()) / 8), static_cast(video_frame_rate())); while (current < len) { DCPTime end = min (len, current + DCPTime::from_frames (reel_in_frames, video_frame_rate ())); - p.push_back (DCPTimePeriod (current, end)); + periods.emplace_back(current, end); current = end; } break; } } - return p; + return periods; } + /** @param period A period within the DCP * @return Name of the content which most contributes to the given period. */ diff --git a/src/lib/film.h b/src/lib/film.h index 036bbed7e..a5cefa4d4 100644 --- a/src/lib/film.h +++ b/src/lib/film.h @@ -186,7 +186,7 @@ public: return _playlist; } - std::list reels () const; + std::vector reels() const; std::list mapped_audio_channels () const; boost::optional audio_language () const { -- 2.30.2