ipa: rpi: Use r-value references in the set()/setLocked() functions

Use an r-value reference in set() and setLocked(), allowing more
efficient metadata handling with std::forward and std::move if needed.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
Naushir Patuck 2025-01-08 11:09:33 +00:00 committed by Kieran Bingham
parent 2d4660b51a
commit 031a57bcd2

View file

@ -12,6 +12,7 @@
#include <map> #include <map>
#include <mutex> #include <mutex>
#include <string> #include <string>
#include <utility>
#include <libcamera/base/thread_annotations.h> #include <libcamera/base/thread_annotations.h>
@ -36,10 +37,10 @@ public:
} }
template<typename T> template<typename T>
void set(std::string const &tag, T const &value) void set(std::string const &tag, T &&value)
{ {
std::scoped_lock lock(mutex_); std::scoped_lock lock(mutex_);
data_[tag] = value; data_[tag] = std::forward<T>(value);
} }
template<typename T> template<typename T>
@ -104,10 +105,10 @@ public:
} }
template<typename T> template<typename T>
void setLocked(std::string const &tag, T const &value) void setLocked(std::string const &tag, T &&value)
{ {
/* Use this only if you're holding the lock yourself. */ /* Use this only if you're holding the lock yourself. */
data_[tag] = value; data_[tag] = std::forward<T>(value);
} }
/* /*