summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2019-10-07 22:39:19 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2019-10-13 20:37:44 +0300
commit764ff6fdf3145868d8b6f91c6a93072d7b86ecaf (patch)
tree0d2c7d31043ce62ef3569eb813dcec459160d22a /src
parentabe2c1b55c788873ee1a24dc207cad82f931a48e (diff)
libcamera: v4l2_device: Avoid copy of V4L2ControlInfo
The V4L2Device::listControls() method creates an instance of V4L2ControlInfo and then inserts it in the device's list of controls. The insertion uses std::map::emplace(), but passes the V4L2ControlInfo, resulting in a copy being performed (using the copy constructor of V4L2ControlInfo). Optimise this by really constructing the V4L2ControlInfo in-place. The use of std::piecewise_construct is required for gcc-5 that seems to have trouble with std::map::emplace() on non-copyable values in this case. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Acked-by: Jacopo Mondi <jacopo@jmondi.org> Tested-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Diffstat (limited to 'src')
-rw-r--r--src/libcamera/v4l2_device.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp
index fd4b9c6d..3bd82ff2 100644
--- a/src/libcamera/v4l2_device.cpp
+++ b/src/libcamera/v4l2_device.cpp
@@ -352,8 +352,7 @@ void V4L2Device::listControls()
ctrl.flags & V4L2_CTRL_FLAG_DISABLED)
continue;
- V4L2ControlInfo info(ctrl);
- switch (info.type()) {
+ switch (ctrl.type) {
case V4L2_CTRL_TYPE_INTEGER:
case V4L2_CTRL_TYPE_BOOLEAN:
case V4L2_CTRL_TYPE_MENU:
@@ -364,12 +363,14 @@ void V4L2Device::listControls()
break;
/* \todo Support compound controls. */
default:
- LOG(V4L2, Debug) << "Control type '" << info.type()
+ LOG(V4L2, Debug) << "Control type '" << ctrl.type
<< "' not supported";
continue;
}
- controls_.emplace(ctrl.id, info);
+ controls_.emplace(std::piecewise_construct,
+ std::forward_as_tuple(ctrl.id),
+ std::forward_as_tuple(ctrl));
}
}