{"id":556,"url":"https://patchwork.libcamera.org/api/patches/556/?format=json","web_url":"https://patchwork.libcamera.org/patch/556/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20190212222021.28517-4-jacopo@jmondi.org>","date":"2019-02-12T22:20:20","name":"[libcamera-devel,3/4] libcamera: device_enumerator: Remove move() on search() return","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"8f42b3cef2aa8fe9d71009de99c9d43af8cf775b","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/?format=json","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/556/mbox/","series":[{"id":175,"url":"https://patchwork.libcamera.org/api/series/175/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=175","date":"2019-02-12T22:20:17","name":"libcamera: mixed updated","version":1,"mbox":"https://patchwork.libcamera.org/series/175/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/556/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/556/checks/","tags":{},"headers":{"Return-Path":"<jacopo@jmondi.org>","Received":["from relay11.mail.gandi.net (relay11.mail.gandi.net\n\t[217.70.178.231])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3882860B21\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 12 Feb 2019 23:20:10 +0100 (CET)","from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101])\n\t(Authenticated sender: jacopo@jmondi.org)\n\tby relay11.mail.gandi.net (Postfix) with ESMTPSA id 61A4D100002;\n\tTue, 12 Feb 2019 22:20:09 +0000 (UTC)"],"From":"Jacopo Mondi <jacopo@jmondi.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Tue, 12 Feb 2019 23:20:20 +0100","Message-Id":"<20190212222021.28517-4-jacopo@jmondi.org>","X-Mailer":"git-send-email 2.20.1","In-Reply-To":"<20190212222021.28517-1-jacopo@jmondi.org>","References":"<20190212222021.28517-1-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH 3/4] libcamera: device_enumerator: Remove\n\tmove() on search() return","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Tue, 12 Feb 2019 22:20:10 -0000"},"content":"Remove the std::move() call on the shared_ptr<MediaDevice *> returned by\nthe search() method and remove the std::move() call on temporary return\nvalue in pipeline handlers that use the method.\n\nThanks to copy elision, the regular constructor of the newly created\nobject is called, avoiding un-necessary copies.\n\nFurthermore, the use of std::move() in the return and assignment\nstatements prevents the compiler from performing copy elision, forcing\nit to generate two sequences of un-necessary calls to the class'\nmove constructor and destructor.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/libcamera/device_enumerator.cpp   | 2 +-\n src/libcamera/pipeline/ipu3/ipu3.cpp  | 4 ++--\n src/libcamera/pipeline/uvcvideo.cpp   | 2 +-\n src/libcamera/pipeline/vimc.cpp       | 2 +-\n test/v4l2_device/v4l2_device_test.cpp | 2 +-\n 5 files changed, 6 insertions(+), 6 deletions(-)","diff":"diff --git a/src/libcamera/device_enumerator.cpp b/src/libcamera/device_enumerator.cpp\nindex 03923b3bb457..7db40812906b 100644\n--- a/src/libcamera/device_enumerator.cpp\n+++ b/src/libcamera/device_enumerator.cpp\n@@ -308,7 +308,7 @@ std::shared_ptr<MediaDevice> DeviceEnumerator::search(const DeviceMatch &dm)\n \t\t\tLOG(DeviceEnumerator, Debug)\n \t\t\t\t<< \"Successful match for media device \\\"\"\n \t\t\t\t<< media->driver() << \"\\\"\";\n-\t\t\treturn std::move(media);\n+\t\t\treturn media;\n \t\t}\n \t}\n \ndiff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\nindex 34b03995ae31..f11e9cc61283 100644\n--- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n@@ -279,11 +279,11 @@ bool PipelineHandlerIPU3::match(DeviceEnumerator *enumerator)\n \timgu_dm.add(\"ipu3-imgu 1 viewfinder\");\n \timgu_dm.add(\"ipu3-imgu 1 3a stat\");\n \n-\tcio2_ = std::move(enumerator->search(cio2_dm));\n+\tcio2_ = enumerator->search(cio2_dm);\n \tif (!cio2_)\n \t\treturn false;\n \n-\timgu_ = std::move(enumerator->search(imgu_dm));\n+\timgu_ = enumerator->search(imgu_dm);\n \tif (!imgu_)\n \t\treturn false;\n \ndiff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp\nindex fc31c52c0ecd..bf0d2fee3851 100644\n--- a/src/libcamera/pipeline/uvcvideo.cpp\n+++ b/src/libcamera/pipeline/uvcvideo.cpp\n@@ -139,7 +139,7 @@ bool PipelineHandlerUVC::match(DeviceEnumerator *enumerator)\n {\n \tDeviceMatch dm(\"uvcvideo\");\n \n-\tmedia_ = std::move(enumerator->search(dm));\n+\tmedia_ = enumerator->search(dm);\n \n \tif (!media_)\n \t\treturn false;\ndiff --git a/src/libcamera/pipeline/vimc.cpp b/src/libcamera/pipeline/vimc.cpp\nindex 46840a4f4104..3aed24c3158a 100644\n--- a/src/libcamera/pipeline/vimc.cpp\n+++ b/src/libcamera/pipeline/vimc.cpp\n@@ -148,7 +148,7 @@ bool PipelineHandlerVimc::match(DeviceEnumerator *enumerator)\n \tdm.add(\"RGB/YUV Input\");\n \tdm.add(\"Scaler\");\n \n-\tmedia_ = std::move(enumerator->search(dm));\n+\tmedia_ = enumerator->search(dm);\n \tif (!media_)\n \t\treturn false;\n \ndiff --git a/test/v4l2_device/v4l2_device_test.cpp b/test/v4l2_device/v4l2_device_test.cpp\nindex 18d014caf4c8..76f2e55d8cb4 100644\n--- a/test/v4l2_device/v4l2_device_test.cpp\n+++ b/test/v4l2_device/v4l2_device_test.cpp\n@@ -40,7 +40,7 @@ int V4L2DeviceTest::init()\n \t}\n \n \tDeviceMatch dm(\"uvcvideo\");\n-\tmedia_ = std::move(enumerator_->search(dm));\n+\tmedia_ = enumerator_->search(dm);\n \tif (!media_)\n \t\treturn TestSkip;\n \n","prefixes":["libcamera-devel","3/4"]}