From patchwork Tue Jan 14 20:14:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 2648 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5BBF26074F for ; Tue, 14 Jan 2020 21:15:08 +0100 (CET) Received: from pendragon.ideasonboard.com (cpc108967-cmbg20-2-0-cust420.5-4.cable.virginm.net [81.101.7.165]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 9EDD02D2 for ; Tue, 14 Jan 2020 21:15:07 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1579032908; bh=7dlhlvI0OVOJAmF+Jtxhr+H8kdmIzNwt/mATHPs8BeI=; h=From:To:Subject:Date:From; b=NAl+Pbaw285HuR+ZFhKu4SDgwd1Bdg0gYePwTTdDy/OsAx9EvNXB4ecrSFNFSrHua ur5mmHlpWcjpdhiPp4qIDu/DIqzrg8vNxuZ1y0bgnXoqIASJ7WsOxe+DznSXl3jkmz BLXR5GKhoubvMsn/ANOHPRRvIgw33ljV4NqLDqAQ= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Tue, 14 Jan 2020 22:14:52 +0200 Message-Id: <20200114201452.14078-1-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.24.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] libcamera: Remove std::piecewise_construct where not necessary X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Jan 2020 20:15:08 -0000 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 Reviewed-by: Niklas Söderlund Reviewed-by: Kieran Bingham --- 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);