From 37283b68eacbcb0a234c1bd21eedaa22323240b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A1s=20P=C5=91cze?= Date: Mon, 31 Mar 2025 16:22:47 +0200 Subject: libcamera: camera_manager: Take camera id in `std::string_view` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Do not force the caller to have an `std::string` object as a simple string view is sufficient to do the lookup. Signed-off-by: Barnabás Pőcze Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- include/libcamera/camera_manager.h | 3 ++- src/libcamera/camera_manager.cpp | 2 +- src/py/libcamera/py_camera_manager.h | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/include/libcamera/camera_manager.h b/include/libcamera/camera_manager.h index b50df782..27835500 100644 --- a/include/libcamera/camera_manager.h +++ b/include/libcamera/camera_manager.h @@ -9,6 +9,7 @@ #include #include +#include #include #include @@ -31,7 +32,7 @@ public: void stop(); std::vector> cameras() const; - std::shared_ptr get(const std::string &id); + std::shared_ptr get(std::string_view id); static const std::string &version() { return version_; } diff --git a/src/libcamera/camera_manager.cpp b/src/libcamera/camera_manager.cpp index b28bd0bd..e62e7193 100644 --- a/src/libcamera/camera_manager.cpp +++ b/src/libcamera/camera_manager.cpp @@ -381,7 +381,7 @@ std::vector> CameraManager::cameras() const * * \return Shared pointer to Camera object or nullptr if camera not found */ -std::shared_ptr CameraManager::get(const std::string &id) +std::shared_ptr CameraManager::get(std::string_view id) { Private *const d = _d(); diff --git a/src/py/libcamera/py_camera_manager.h b/src/py/libcamera/py_camera_manager.h index 3574db23..af69b915 100644 --- a/src/py/libcamera/py_camera_manager.h +++ b/src/py/libcamera/py_camera_manager.h @@ -20,7 +20,7 @@ public: ~PyCameraManager(); pybind11::list cameras(); - std::shared_ptr get(const std::string &name) { return cameraManager_->get(name); } + std::shared_ptr get(std::string_view name) { return cameraManager_->get(name); } static const std::string &version() { return CameraManager::version(); } -- cgit v1.2.1