From 5eaf4fed19909a954281a8b37bf5297b3cb2815f Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Sat, 15 Feb 2020 22:44:03 +0200 Subject: libcamera: controls: Return control by value The ControlList::get() and ControlValue::get() methods return the control value by reference. This requires the ControlValue class to store the control value in the same form as the one returned by those functions. For the array controls that are soon to be added, the ControlValue class would need to store a span<> instance in addition to the control value itself, which would increase the required storage space. Prepare for support of array controls by returning from get() by value. As all control values are 8 bytes at most, this doesn't affect efficiency negatively. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- include/libcamera/controls.h | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h index 9d93064c..3b6b231c 100644 --- a/include/libcamera/controls.h +++ b/include/libcamera/controls.h @@ -42,7 +42,7 @@ public: } template - const T &get() const; + T get() const; template void set(const T &value); @@ -212,13 +212,11 @@ public: bool contains(unsigned int id) const; template - const T &get(const Control &ctrl) const + T get(const Control &ctrl) const { const ControlValue *val = find(ctrl.id()); - if (!val) { - static T t(0); - return t; - } + if (!val) + return T{}; return val->get(); } -- cgit v1.2.1