[libcamera-devel] [PATCH] libcamera: Remove std::piecewise_construct where not necessary
Niklas Söderlund
niklas.soderlund at ragnatech.se
Wed Jan 15 20:35:54 CET 2020
Hi Laurent,
Thanks for your patch.
On 2020-01-14 22:14:52 +0200, Laurent Pinchart wrote:
> When emplacing an element in a std::map, std::piecewise_construct is
> required to forward the parameters to the constructors of the key and
> mapped type, respectively. However, when the caller already has an
> instance of the mapped type, forwarding it to the mapped type copy
> constructor isn't really required, as the copy constructor would be
> called anyway. Drop std::piecewise_construct in those cases. This does
> not incur any performance cost.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund at ragnatech.se>
> ---
> src/libcamera/pipeline/uvcvideo.cpp | 4 +---
> src/libcamera/pipeline/vimc.cpp | 4 +---
> 2 files changed, 2 insertions(+), 6 deletions(-)
>
> diff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp
> index 83093676ec73..29afb121aa46 100644
> --- a/src/libcamera/pipeline/uvcvideo.cpp
> +++ b/src/libcamera/pipeline/uvcvideo.cpp
> @@ -365,9 +365,7 @@ int UVCCameraData::init(MediaEntity *entity)
> continue;
> }
>
> - ctrls.emplace(std::piecewise_construct,
> - std::forward_as_tuple(id),
> - std::forward_as_tuple(range));
> + ctrls.emplace(id, range);
> }
>
> controlInfo_ = std::move(ctrls);
> diff --git a/src/libcamera/pipeline/vimc.cpp b/src/libcamera/pipeline/vimc.cpp
> index c99560a45cfa..b1054d307ea2 100644
> --- a/src/libcamera/pipeline/vimc.cpp
> +++ b/src/libcamera/pipeline/vimc.cpp
> @@ -448,9 +448,7 @@ int VimcCameraData::init(MediaDevice *media)
> continue;
> }
>
> - ctrls.emplace(std::piecewise_construct,
> - std::forward_as_tuple(id),
> - std::forward_as_tuple(range));
> + ctrls.emplace(id, range);
> }
>
> controlInfo_ = std::move(ctrls);
> --
> Regards,
>
> Laurent Pinchart
>
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel at lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel
--
Regards,
Niklas Söderlund
More information about the libcamera-devel
mailing list