[vlc-devel] [PATCH 01/14] mkv: introduced helper functions related to indexes

Filipe Cabecinhas filcab at filcab.net
Thu Mar 10 13:00:57 CET 2016


Why replace "indexes.begin()", which is pretty standard with
"indexes_begin()", which has more cognitive load with seemingly no gain?

Thanks,

  Filipe

On Wednesday, 9 March 2016, Filip Roséen <filip at videolabs.io> wrote:

> ---
>  modules/demux/mkv/matroska_segment.cpp | 8 +++-----
>  modules/demux/mkv/matroska_segment.hpp | 7 +++++--
>  modules/demux/mkv/mkv.cpp              | 4 ++--
>  3 files changed, 10 insertions(+), 9 deletions(-)
>
> diff --git a/modules/demux/mkv/matroska_segment.cpp
> b/modules/demux/mkv/matroska_segment.cpp
> index ca72176..64d775b 100644
> --- a/modules/demux/mkv/matroska_segment.cpp
> +++ b/modules/demux/mkv/matroska_segment.cpp
> @@ -893,13 +893,11 @@ void matroska_segment_c::Seek( mtime_t i_mk_date,
> mtime_t i_mk_time_offset, int6
>          return;
>      }
>
> -    indexes_t::const_iterator index_it = indexes.begin ();
> +    indexes_t::const_iterator index_it = indexes_begin ();
>
>      if ( index_idx() )
>      {
> -        indexes_t::const_iterator last_active_it = indexes.end() - 1;
> -
> -        for( ; index_it != last_active_it; ++index_it )
> +        for( ; index_it != indexes_end(); ++index_it )
>          {
>              if (index_it->i_mk_time == -1)
>                  continue;
> @@ -908,7 +906,7 @@ void matroska_segment_c::Seek( mtime_t i_mk_date,
> mtime_t i_mk_time_offset, int6
>                  break;
>          }
>
> -        if( index_it != indexes.begin ())
> +        if( index_it != indexes_begin ())
>              --index_it;
>
>          i_seek_position = index_it->i_position;
> diff --git a/modules/demux/mkv/matroska_segment.hpp
> b/modules/demux/mkv/matroska_segment.hpp
> index cab3702..a1b8b92 100644
> --- a/modules/demux/mkv/matroska_segment.hpp
> +++ b/modules/demux/mkv/matroska_segment.hpp
> @@ -145,8 +145,11 @@ public:
>      void UnSelect();
>
>      size_t        index_idx () const { return indexes.size () - 1; }
> -    mkv_index_t&      index () { return *indexes.rbegin (); }
> -    mkv_index_t& prev_index () { return *(indexes.end()-2); }
> +    mkv_index_t&      index ()       { return *(indexes.rbegin()); }
> +    mkv_index_t& prev_index ()       { return *(indexes.rbegin()+1); }
> +
> +    indexes_t::iterator indexes_begin () { return indexes.begin(); }
> +    indexes_t::iterator indexes_end   () { return indexes.end() -
> (indexes.size() ? 1 : 0); }
>
>      static bool CompareSegmentUIDs( const matroska_segment_c * item_a,
> const matroska_segment_c * item_b );
>
> diff --git a/modules/demux/mkv/mkv.cpp b/modules/demux/mkv/mkv.cpp
> index 35b52c7..cd31bb7 100644
> --- a/modules/demux/mkv/mkv.cpp
> +++ b/modules/demux/mkv/mkv.cpp
> @@ -475,8 +475,8 @@ static void Seek( demux_t *p_demux, mtime_t i_mk_date,
> double f_percent, virtual
>
>              if (p_segment->indexes.size())
>              {
> -                matroska_segment_c::indexes_t::iterator it          =
> p_segment->indexes.begin ();
> -                matroska_segment_c::indexes_t::iterator last_active =
> p_segment->indexes.end()-1;
> +                matroska_segment_c::indexes_t::iterator it          =
> p_segment->indexes_begin ();
> +                matroska_segment_c::indexes_t::iterator last_active =
> p_segment->indexes_end ();
>
>                  for ( ; it != last_active; ++it )
>                  {
> --
> 2.7.2
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20160310/34b3510b/attachment.html>


More information about the vlc-devel mailing list