From 3e9bb94126bdc6dada0b837f2f636935f93abdf1 Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Fri, 21 Mar 2014 16:11:56 -0700 Subject: [PATCH] Use boost range algorithms in audio_timing_dialogue.cpp --- src/audio_timing_dialogue.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/audio_timing_dialogue.cpp b/src/audio_timing_dialogue.cpp index 5c85983e6..d3edd11f2 100644 --- a/src/audio_timing_dialogue.cpp +++ b/src/audio_timing_dialogue.cpp @@ -31,9 +31,7 @@ /// @brief Default timing mode for dialogue subtitles /// @ingroup audio_ui - -#include -#include +#include "config.h" #include "ass_dialogue.h" #include "ass_file.h" @@ -47,6 +45,10 @@ #include "selection_controller.h" #include "utils.h" +#include +#include +#include + class TimeableLine; /// @class DialogueTimingMarker @@ -446,8 +448,8 @@ void AudioTimingControllerDialogue::GetMarkers(const TimeRange &range, AudioMark // Copy inactive line markers in the range copy( - lower_bound(markers.begin(), markers.end(), range.begin(), marker_ptr_cmp()), - upper_bound(markers.begin(), markers.end(), range.end(), marker_ptr_cmp()), + boost::lower_bound(markers, range.begin(), marker_ptr_cmp()), + boost::upper_bound(markers, range.end(), marker_ptr_cmp()), back_inserter(out_markers)); keyframes_provider.GetMarkers(range, out_markers); @@ -520,7 +522,7 @@ void AudioTimingControllerDialogue::Next(NextMode mode) // same marker gets set twice active_line.GetRightMarker()->SetPosition(new_end_ms + default_duration); active_line.GetLeftMarker()->SetPosition(new_end_ms); - sort(markers.begin(), markers.end(), marker_ptr_cmp()); + boost::sort(markers, marker_ptr_cmp()); modified_lines.insert(&active_line); UpdateSelection(); } @@ -646,7 +648,7 @@ std::vector AudioTimingControllerDialogue::OnLeftClick(int ms, boo { // The use of GetPosition here is important, as otherwise it'll start // after lines ending at the same time as the active line begins - auto it = lower_bound(markers.begin(), markers.end(), clicked->GetPosition(), marker_ptr_cmp()); + auto it = boost::lower_bound(markers, clicked->GetPosition(), marker_ptr_cmp()); for(; it != markers.end() && !(*clicked < **it); ++it) ret.push_back(*it); } @@ -693,7 +695,7 @@ void AudioTimingControllerDialogue::SetMarkers(std::vector const& max_ms = std::max(*marker, max_ms); } - auto begin = lower_bound(markers.begin(), markers.end(), min_ms, marker_ptr_cmp()); + auto begin = boost::lower_bound(markers, min_ms, marker_ptr_cmp()); auto end = upper_bound(begin, markers.end(), max_ms, marker_ptr_cmp()); // Update the markers @@ -850,7 +852,7 @@ int AudioTimingControllerDialogue::SnapPosition(int position, int snap_range, st GetMarkers(snap_time_range, potential_snaps); for (auto marker : potential_snaps) { - if (marker->CanSnap() && find(exclude.begin(), exclude.end(), marker) == exclude.end()) + if (marker->CanSnap() && boost::find(exclude, marker) == exclude.end()) { if (!snap_marker) snap_marker = marker;