Commit 9891f892 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

Use emplace_back instead of push_back

parent 7602f030
...@@ -222,7 +222,7 @@ public: ...@@ -222,7 +222,7 @@ public:
std::vector<ModuleDescription> res; std::vector<ModuleDescription> res;
while ( p != NULL ) while ( p != NULL )
{ {
res.push_back( ModuleDescription( p ) ); res.emplace_back( p );
p = p->p_next; p = p->p_next;
} }
return res; return res;
...@@ -250,7 +250,7 @@ public: ...@@ -250,7 +250,7 @@ public:
std::vector<ModuleDescription> res; std::vector<ModuleDescription> res;
while ( p != NULL ) while ( p != NULL )
{ {
res.push_back( ModuleDescription( p ) ); res.emplace_back( p );
p = p->p_next; p = p->p_next;
} }
return res; return res;
...@@ -274,7 +274,7 @@ public: ...@@ -274,7 +274,7 @@ public:
libvlc_audio_output_t* p = result; libvlc_audio_output_t* p = result;
while ( p != NULL ) while ( p != NULL )
{ {
res.push_back( AudioOutputDescription( p ) ); res.emplace_back( p );
p = p->p_next; p = p->p_next;
} }
libvlc_audio_output_list_release(result); libvlc_audio_output_list_release(result);
...@@ -310,7 +310,7 @@ public: ...@@ -310,7 +310,7 @@ public:
if ( devices == NULL ) if ( devices == NULL )
return res; return res;
for ( libvlc_audio_output_device_t* p = devices; p != NULL; p = p->p_next ) for ( libvlc_audio_output_device_t* p = devices; p != NULL; p = p->p_next )
res.push_back( AudioOutputDeviceDescription( p ) ); res.emplace_back( p );
libvlc_audio_output_device_list_release( devices ); libvlc_audio_output_device_list_release( devices );
return res; return res;
} }
......
...@@ -425,7 +425,7 @@ public: ...@@ -425,7 +425,7 @@ public:
return res; return res;
for ( uint32_t i = 0; i < nbTracks; ++i ) for ( uint32_t i = 0; i < nbTracks; ++i )
res.push_back( MediaTrack(tracks[i])); res.emplace_back( tracks[i] );
libvlc_media_tracks_release( tracks, nbTracks ); libvlc_media_tracks_release( tracks, nbTracks );
return res; return res;
} }
......
...@@ -816,8 +816,8 @@ public: ...@@ -816,8 +816,8 @@ public:
std::vector<AudioOutputDeviceDescription> res; std::vector<AudioOutputDeviceDescription> res;
if ( devices == NULL ) if ( devices == NULL )
return res; return res;
for ( libvlc_audio_output_device_t* p = devices; p != NULL; p = p->p_next ) for ( auto* p = devices; p != NULL; p = p->p_next )
res.push_back( AudioOutputDeviceDescription( p ) ); res.emplace_back( p );
libvlc_audio_output_device_list_release( devices ); libvlc_audio_output_device_list_release( devices );
return res; return res;
} }
...@@ -1643,7 +1643,7 @@ private: ...@@ -1643,7 +1643,7 @@ private:
libvlc_track_description_t* p = tracks; libvlc_track_description_t* p = tracks;
while ( p != NULL ) while ( p != NULL )
{ {
result.push_back( TrackDescription( p ) ); result.emplace_back( p );
p = p->p_next; p = p->p_next;
} }
libvlc_track_description_list_release(tracks); libvlc_track_description_list_release(tracks);
......
...@@ -28,12 +28,12 @@ ...@@ -28,12 +28,12 @@
#include "common.hpp" #include "common.hpp"
//FIXME:
//Should we make the constructors private again and implement our own vector allocator?
namespace VLC namespace VLC
{ {
class Instance;
class Media;
class ModuleDescription class ModuleDescription
{ {
public: public:
...@@ -57,7 +57,6 @@ public: ...@@ -57,7 +57,6 @@ public:
return m_help; return m_help;
} }
private:
explicit ModuleDescription( libvlc_module_description_t* c ) explicit ModuleDescription( libvlc_module_description_t* c )
{ {
if ( c->psz_name != NULL ) if ( c->psz_name != NULL )
...@@ -70,12 +69,11 @@ private: ...@@ -70,12 +69,11 @@ private:
m_help = c->psz_help; m_help = c->psz_help;
} }
private:
std::string m_name; std::string m_name;
std::string m_shortname; std::string m_shortname;
std::string m_longname; std::string m_longname;
std::string m_help; std::string m_help;
friend class Instance;
}; };
...@@ -183,7 +181,6 @@ public: ...@@ -183,7 +181,6 @@ public:
return m_encoding; return m_encoding;
} }
private:
explicit MediaTrack(libvlc_media_track_t* c) explicit MediaTrack(libvlc_media_track_t* c)
: m_codec( c->i_codec ) : m_codec( c->i_codec )
, m_originalFourcc( c->i_original_fourcc ) , m_originalFourcc( c->i_original_fourcc )
...@@ -224,6 +221,7 @@ private: ...@@ -224,6 +221,7 @@ private:
} }
} }
private:
uint32_t m_codec; uint32_t m_codec;
uint32_t m_originalFourcc; uint32_t m_originalFourcc;
uint32_t m_id; uint32_t m_id;
...@@ -245,8 +243,6 @@ private: ...@@ -245,8 +243,6 @@ private:
uint32_t m_fpsDen; uint32_t m_fpsDen;
// Subtitles // Subtitles
std::string m_encoding; std::string m_encoding;
friend class Media;
}; };
...@@ -263,8 +259,7 @@ public: ...@@ -263,8 +259,7 @@ public:
return m_description; return m_description;
} }
private: explicit AudioOutputDescription( libvlc_audio_output_t* c )
AudioOutputDescription( libvlc_audio_output_t* c )
{ {
if ( c->psz_name != NULL ) if ( c->psz_name != NULL )
m_name = c->psz_name; m_name = c->psz_name;
...@@ -272,10 +267,9 @@ private: ...@@ -272,10 +267,9 @@ private:
m_description = c->psz_description; m_description = c->psz_description;
} }
private:
std::string m_name; std::string m_name;
std::string m_description; std::string m_description;
friend class Instance;
}; };
class AudioOutputDeviceDescription class AudioOutputDeviceDescription
...@@ -293,7 +287,6 @@ class AudioOutputDeviceDescription ...@@ -293,7 +287,6 @@ class AudioOutputDeviceDescription
return m_description; return m_description;
} }
private:
explicit AudioOutputDeviceDescription( libvlc_audio_output_device_t* d ) explicit AudioOutputDeviceDescription( libvlc_audio_output_device_t* d )
{ {
if ( d->psz_device != NULL ) if ( d->psz_device != NULL )
...@@ -302,11 +295,9 @@ class AudioOutputDeviceDescription ...@@ -302,11 +295,9 @@ class AudioOutputDeviceDescription
m_device = d->psz_description; m_device = d->psz_description;
} }
private:
std::string m_device; std::string m_device;
std::string m_description; std::string m_description;
friend class Instance;
friend class MediaPlayer;
}; };
class TrackDescription class TrackDescription
...@@ -322,17 +313,16 @@ public: ...@@ -322,17 +313,16 @@ public:
return m_name; return m_name;
} }
private:
explicit TrackDescription( libvlc_track_description_t* c ) explicit TrackDescription( libvlc_track_description_t* c )
: m_id( c->i_id ) : m_id( c->i_id )
{ {
if ( c->psz_name != nullptr ) if ( c->psz_name != nullptr )
m_name = c->psz_name; m_name = c->psz_name;
} }
private:
int m_id; int m_id;
std::string m_name; std::string m_name;
friend class MediaPlayer;
}; };
} // namespace VLC } // namespace VLC
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment