Message ID | 20191013232755.3292-9-laurent.pinchart@ideasonboard.com |
---|---|
State | Accepted |
Headers | show |
Series |
|
Related | show |
Hi Laurent, Thanks for your patch. On 2019-10-14 02:27:54 +0300, Laurent Pinchart wrote: > Replace the std::map<> used as the base type for V4L2ControlInfoMap by > ControlInfoMap, which is an alias for an std::unsorted_map<> with the > same key and value types. This shortens the code. > > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> > --- > src/libcamera/include/v4l2_controls.h | 34 +++++++++++++-------------- > src/libcamera/v4l2_controls.cpp | 6 ++--- > src/libcamera/v4l2_device.cpp | 2 +- > 3 files changed, 21 insertions(+), 21 deletions(-) > > diff --git a/src/libcamera/include/v4l2_controls.h b/src/libcamera/include/v4l2_controls.h > index 7d3528b07f94..c427b845d8b4 100644 > --- a/src/libcamera/include/v4l2_controls.h > +++ b/src/libcamera/include/v4l2_controls.h > @@ -31,27 +31,27 @@ public: > V4L2ControlRange(const struct v4l2_query_ext_ctrl &ctrl); > }; > > -class V4L2ControlInfoMap : private std::map<const ControlId *, ControlRange> > +class V4L2ControlInfoMap : private ControlInfoMap > { > public: > - V4L2ControlInfoMap &operator=(std::map<const ControlId *, ControlRange> &&info); > + V4L2ControlInfoMap &operator=(ControlInfoMap &&info); > > - using std::map<const ControlId *, ControlRange>::key_type; > - using std::map<const ControlId *, ControlRange>::mapped_type; > - using std::map<const ControlId *, ControlRange>::value_type; > - using std::map<const ControlId *, ControlRange>::size_type; > - using std::map<const ControlId *, ControlRange>::iterator; > - using std::map<const ControlId *, ControlRange>::const_iterator; > + using ControlInfoMap::key_type; > + using ControlInfoMap::mapped_type; > + using ControlInfoMap::value_type; > + using ControlInfoMap::size_type; > + using ControlInfoMap::iterator; > + using ControlInfoMap::const_iterator; > > - using std::map<const ControlId *, ControlRange>::begin; > - using std::map<const ControlId *, ControlRange>::cbegin; > - using std::map<const ControlId *, ControlRange>::end; > - using std::map<const ControlId *, ControlRange>::cend; > - using std::map<const ControlId *, ControlRange>::at; > - using std::map<const ControlId *, ControlRange>::empty; > - using std::map<const ControlId *, ControlRange>::size; > - using std::map<const ControlId *, ControlRange>::count; > - using std::map<const ControlId *, ControlRange>::find; > + using ControlInfoMap::begin; > + using ControlInfoMap::cbegin; > + using ControlInfoMap::end; > + using ControlInfoMap::cend; > + using ControlInfoMap::at; > + using ControlInfoMap::empty; > + using ControlInfoMap::size; > + using ControlInfoMap::count; > + using ControlInfoMap::find; > > mapped_type &at(unsigned int key); > const mapped_type &at(unsigned int key) const; > diff --git a/src/libcamera/v4l2_controls.cpp b/src/libcamera/v4l2_controls.cpp > index e27c70eeec87..e783457caf94 100644 > --- a/src/libcamera/v4l2_controls.cpp > +++ b/src/libcamera/v4l2_controls.cpp > @@ -140,7 +140,7 @@ V4L2ControlRange::V4L2ControlRange(const struct v4l2_query_ext_ctrl &ctrl) > */ > > /** > - * \brief Move assignment operator from plain map > + * \brief Move assignment operator from a ControlInfoMap > * \param[in] info The control info map > * > * Populate the map by replacing its contents with those of \a info using move > @@ -150,9 +150,9 @@ V4L2ControlRange::V4L2ControlRange(const struct v4l2_query_ext_ctrl &ctrl) > * > * \return The populated V4L2ControlInfoMap > */ > -V4L2ControlInfoMap &V4L2ControlInfoMap::operator=(std::map<const ControlId *, ControlRange> &&info) > +V4L2ControlInfoMap &V4L2ControlInfoMap::operator=(ControlInfoMap &&info) > { > - std::map<const ControlId *, ControlRange>::operator=(std::move(info)); > + ControlInfoMap::operator=(std::move(info)); > > idmap_.clear(); > for (const auto &ctrl : *this) > diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp > index 47999e70073c..06155eb51c03 100644 > --- a/src/libcamera/v4l2_device.cpp > +++ b/src/libcamera/v4l2_device.cpp > @@ -342,7 +342,7 @@ int V4L2Device::ioctl(unsigned long request, void *argp) > */ > void V4L2Device::listControls() > { > - std::map<const ControlId *, ControlRange> ctrls; > + ControlInfoMap ctrls; > struct v4l2_query_ext_ctrl ctrl = {}; > > /* \todo Add support for menu and compound controls. */ > -- > Regards, > > Laurent Pinchart > > _______________________________________________ > libcamera-devel mailing list > libcamera-devel@lists.libcamera.org > https://lists.libcamera.org/listinfo/libcamera-devel
Hi Laurent, On Mon, Oct 14, 2019 at 02:27:54AM +0300, Laurent Pinchart wrote: > Replace the std::map<> used as the base type for V4L2ControlInfoMap by > ControlInfoMap, which is an alias for an std::unsorted_map<> with the > same key and value types. This shortens the code. Looks good! Thanks j > > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> > --- > src/libcamera/include/v4l2_controls.h | 34 +++++++++++++-------------- > src/libcamera/v4l2_controls.cpp | 6 ++--- > src/libcamera/v4l2_device.cpp | 2 +- > 3 files changed, 21 insertions(+), 21 deletions(-) > > diff --git a/src/libcamera/include/v4l2_controls.h b/src/libcamera/include/v4l2_controls.h > index 7d3528b07f94..c427b845d8b4 100644 > --- a/src/libcamera/include/v4l2_controls.h > +++ b/src/libcamera/include/v4l2_controls.h > @@ -31,27 +31,27 @@ public: > V4L2ControlRange(const struct v4l2_query_ext_ctrl &ctrl); > }; > > -class V4L2ControlInfoMap : private std::map<const ControlId *, ControlRange> > +class V4L2ControlInfoMap : private ControlInfoMap > { > public: > - V4L2ControlInfoMap &operator=(std::map<const ControlId *, ControlRange> &&info); > + V4L2ControlInfoMap &operator=(ControlInfoMap &&info); > > - using std::map<const ControlId *, ControlRange>::key_type; > - using std::map<const ControlId *, ControlRange>::mapped_type; > - using std::map<const ControlId *, ControlRange>::value_type; > - using std::map<const ControlId *, ControlRange>::size_type; > - using std::map<const ControlId *, ControlRange>::iterator; > - using std::map<const ControlId *, ControlRange>::const_iterator; > + using ControlInfoMap::key_type; > + using ControlInfoMap::mapped_type; > + using ControlInfoMap::value_type; > + using ControlInfoMap::size_type; > + using ControlInfoMap::iterator; > + using ControlInfoMap::const_iterator; > > - using std::map<const ControlId *, ControlRange>::begin; > - using std::map<const ControlId *, ControlRange>::cbegin; > - using std::map<const ControlId *, ControlRange>::end; > - using std::map<const ControlId *, ControlRange>::cend; > - using std::map<const ControlId *, ControlRange>::at; > - using std::map<const ControlId *, ControlRange>::empty; > - using std::map<const ControlId *, ControlRange>::size; > - using std::map<const ControlId *, ControlRange>::count; > - using std::map<const ControlId *, ControlRange>::find; > + using ControlInfoMap::begin; > + using ControlInfoMap::cbegin; > + using ControlInfoMap::end; > + using ControlInfoMap::cend; > + using ControlInfoMap::at; > + using ControlInfoMap::empty; > + using ControlInfoMap::size; > + using ControlInfoMap::count; > + using ControlInfoMap::find; > > mapped_type &at(unsigned int key); > const mapped_type &at(unsigned int key) const; > diff --git a/src/libcamera/v4l2_controls.cpp b/src/libcamera/v4l2_controls.cpp > index e27c70eeec87..e783457caf94 100644 > --- a/src/libcamera/v4l2_controls.cpp > +++ b/src/libcamera/v4l2_controls.cpp > @@ -140,7 +140,7 @@ V4L2ControlRange::V4L2ControlRange(const struct v4l2_query_ext_ctrl &ctrl) > */ > > /** > - * \brief Move assignment operator from plain map > + * \brief Move assignment operator from a ControlInfoMap > * \param[in] info The control info map > * > * Populate the map by replacing its contents with those of \a info using move > @@ -150,9 +150,9 @@ V4L2ControlRange::V4L2ControlRange(const struct v4l2_query_ext_ctrl &ctrl) > * > * \return The populated V4L2ControlInfoMap > */ > -V4L2ControlInfoMap &V4L2ControlInfoMap::operator=(std::map<const ControlId *, ControlRange> &&info) > +V4L2ControlInfoMap &V4L2ControlInfoMap::operator=(ControlInfoMap &&info) > { > - std::map<const ControlId *, ControlRange>::operator=(std::move(info)); > + ControlInfoMap::operator=(std::move(info)); > > idmap_.clear(); > for (const auto &ctrl : *this) > diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp > index 47999e70073c..06155eb51c03 100644 > --- a/src/libcamera/v4l2_device.cpp > +++ b/src/libcamera/v4l2_device.cpp > @@ -342,7 +342,7 @@ int V4L2Device::ioctl(unsigned long request, void *argp) > */ > void V4L2Device::listControls() > { > - std::map<const ControlId *, ControlRange> ctrls; > + ControlInfoMap ctrls; > struct v4l2_query_ext_ctrl ctrl = {}; > > /* \todo Add support for menu and compound controls. */ > -- > Regards, > > Laurent Pinchart > > _______________________________________________ > libcamera-devel mailing list > libcamera-devel@lists.libcamera.org > https://lists.libcamera.org/listinfo/libcamera-devel
diff --git a/src/libcamera/include/v4l2_controls.h b/src/libcamera/include/v4l2_controls.h index 7d3528b07f94..c427b845d8b4 100644 --- a/src/libcamera/include/v4l2_controls.h +++ b/src/libcamera/include/v4l2_controls.h @@ -31,27 +31,27 @@ public: V4L2ControlRange(const struct v4l2_query_ext_ctrl &ctrl); }; -class V4L2ControlInfoMap : private std::map<const ControlId *, ControlRange> +class V4L2ControlInfoMap : private ControlInfoMap { public: - V4L2ControlInfoMap &operator=(std::map<const ControlId *, ControlRange> &&info); + V4L2ControlInfoMap &operator=(ControlInfoMap &&info); - using std::map<const ControlId *, ControlRange>::key_type; - using std::map<const ControlId *, ControlRange>::mapped_type; - using std::map<const ControlId *, ControlRange>::value_type; - using std::map<const ControlId *, ControlRange>::size_type; - using std::map<const ControlId *, ControlRange>::iterator; - using std::map<const ControlId *, ControlRange>::const_iterator; + using ControlInfoMap::key_type; + using ControlInfoMap::mapped_type; + using ControlInfoMap::value_type; + using ControlInfoMap::size_type; + using ControlInfoMap::iterator; + using ControlInfoMap::const_iterator; - using std::map<const ControlId *, ControlRange>::begin; - using std::map<const ControlId *, ControlRange>::cbegin; - using std::map<const ControlId *, ControlRange>::end; - using std::map<const ControlId *, ControlRange>::cend; - using std::map<const ControlId *, ControlRange>::at; - using std::map<const ControlId *, ControlRange>::empty; - using std::map<const ControlId *, ControlRange>::size; - using std::map<const ControlId *, ControlRange>::count; - using std::map<const ControlId *, ControlRange>::find; + using ControlInfoMap::begin; + using ControlInfoMap::cbegin; + using ControlInfoMap::end; + using ControlInfoMap::cend; + using ControlInfoMap::at; + using ControlInfoMap::empty; + using ControlInfoMap::size; + using ControlInfoMap::count; + using ControlInfoMap::find; mapped_type &at(unsigned int key); const mapped_type &at(unsigned int key) const; diff --git a/src/libcamera/v4l2_controls.cpp b/src/libcamera/v4l2_controls.cpp index e27c70eeec87..e783457caf94 100644 --- a/src/libcamera/v4l2_controls.cpp +++ b/src/libcamera/v4l2_controls.cpp @@ -140,7 +140,7 @@ V4L2ControlRange::V4L2ControlRange(const struct v4l2_query_ext_ctrl &ctrl) */ /** - * \brief Move assignment operator from plain map + * \brief Move assignment operator from a ControlInfoMap * \param[in] info The control info map * * Populate the map by replacing its contents with those of \a info using move @@ -150,9 +150,9 @@ V4L2ControlRange::V4L2ControlRange(const struct v4l2_query_ext_ctrl &ctrl) * * \return The populated V4L2ControlInfoMap */ -V4L2ControlInfoMap &V4L2ControlInfoMap::operator=(std::map<const ControlId *, ControlRange> &&info) +V4L2ControlInfoMap &V4L2ControlInfoMap::operator=(ControlInfoMap &&info) { - std::map<const ControlId *, ControlRange>::operator=(std::move(info)); + ControlInfoMap::operator=(std::move(info)); idmap_.clear(); for (const auto &ctrl : *this) diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp index 47999e70073c..06155eb51c03 100644 --- a/src/libcamera/v4l2_device.cpp +++ b/src/libcamera/v4l2_device.cpp @@ -342,7 +342,7 @@ int V4L2Device::ioctl(unsigned long request, void *argp) */ void V4L2Device::listControls() { - std::map<const ControlId *, ControlRange> ctrls; + ControlInfoMap ctrls; struct v4l2_query_ext_ctrl ctrl = {}; /* \todo Add support for menu and compound controls. */
Replace the std::map<> used as the base type for V4L2ControlInfoMap by ControlInfoMap, which is an alias for an std::unsorted_map<> with the same key and value types. This shortens the code. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> --- src/libcamera/include/v4l2_controls.h | 34 +++++++++++++-------------- src/libcamera/v4l2_controls.cpp | 6 ++--- src/libcamera/v4l2_device.cpp | 2 +- 3 files changed, 21 insertions(+), 21 deletions(-)